March 15, 2018

Sreekanth B

Capgemini ASP.NET MVC Recent Interview Questions And Answers

How To Make Sure Client Validation Is Enabled In Asp.net Mvc?

In Web.Config there are tags called : "ClientValidationEnabled" and "UnobtrusiveJavaScriptEnabled". We can set the client side validation just by setting these two tags "true", then this setting will be applied at the application level.

< add key="ClientValidationEnabled" value="true" />

< add key="UnobtrusiveJavaScriptEnabled" value="true" />

Explain Peek Method In Tempdata In Asp.net Mvc?

Similar to Keep method we have one more method called "Peek" which is used for the same purpose. This method used to read data in Tempdata and it maintains the data for subsequent request.

string A4str = TempData.Peek("TT").ToString();

How We Can Register The Area In Asp.net Mvc?

When we have created an area make sure this will be registered in "Application_Start" event in Global.asax.

Below is the code snippet where area registration is done :

protected void Application_Start()

{

AreaRegistration.RegisterAllAreas();

}

How We Can Invoke Child Actions In Asp.net Mvc?

"ChildActionOnly" attribute is decorated over action methods to indicate that action method is a child action. Below is the code snippet used to denote the child action :

[ChildActionOnly]

public ActionResult MenuBar()

{

//Logic here

return PartialView();

}
Capgemini ASP.NET MVC Recent Interview Questions And Answers

What Is Dependency Injection In Asp.net Mvc?

it's a design pattern and is used for developing loosely couple code. This is greatly used in the software projects. This will reduce the coding in case of changes on project design so this is vastly used.

Explain Test Driven Development (tdd) ?

TDD is a methodology which says, write your tests first before you write your code. In TDD, tests drive your application design and development cycles. You do not do the check-in of your code into source control until all of your unit tests pass.

Explain The Tools Used For Unit Testing In Asp.net Mvc?

Below are the tools used for unit testing :

NUnit
xUnit.NET
Ninject 2
Moq

What Is Representational State Transfer (rest) Mean?

REST is an architectural style which uses HTTP protocol methods like GET, POST, PUT, and DELETE to access the data. ASP.Net MVC works in this style. In ASP.Net MVC 4 there is a support for Web API which uses to build the service using HTTP verbs.

How To Use Jquery Plugins In Asp.net Mvc Validation?

We can use dataannotations for validation in ASP.Net MVC. If we want to use validation during runtime using Jquery then we can use Jquery plugins for validation.

Eg:

If validation is to be done on customer name textbox then we can do as :

$('#CustomerName').rules("add", {

required: true,

minlength: 2,

messages: {

required: "Please enter name",

minlength: "Minimum length is 2"

}

});

Can I Use Razor Code In Javascript In Asp.net Mvc?

Yes. We can use the razor code in javascript in cshtml by using <text> element.

< script type="text/javascript">

@foreach (var item in Model) {

< text >

//javascript goes here which uses the server values

< text >

}

< script>

How Can I Return String Result From Action In Asp.net Mvc?

Below is the code snippet to return string from action method :

public ActionResult TestAction() {

return Content("Hello Test !!");

}

How To Return The Json From Action Method In Asp.net Mvc?

Below is the code snippet to return string from action method :

public ActionResult TestAction() {

return JSON(new { prop1 = "Test1", prop2 = "Test2" });

}

Tell Us Something About Model, View And Controllers In Asp.net Mvc?

Model : It is basically a business entity which is used to represent the application data.

 Controller : The Request which is sent by the user always scatters through controller and it's responsibility is to redirect to the specific view using View () method.

 View : it's the presentation layer of ASP.Net MVC.

Do You Know About The New Features In Asp.net Mvc 4 (asp.net Mvc4)?

Following are features added newly : Mobile templates Added ASP.NET Web API template for creating REST based services. Asynchronous controller task support. Bundling of the java scripts. Segregating the configs for ASP.Net MVC routing, Web API, Bundle etc.

How Does The 'page Lifecycle' Of Asp.net Mvc Works?

Below are the processed followed in the sequence :

App initializWhat is Separation of Concerns in ASP.NET ASP.Net MVCation
Routing
Instantiate and execute controller
Locate and invoke controller action
Instantiate and render view.

Explain The Advantages Of Asp.net Mvc Over Asp.net?

Provides a clean separation of concerns among UI (Presentation layer), model (Transfer objects/Domain Objects/Entities) and Business Logic (Controller).
Easy to UNIT Test.
Improved reusability of model and views. We can have multiple views which can point to the same model and vice versa.
Improved structuring of the code.

What Is Separation Of Concerns In Asp.net Asp.net Mvc?

It is the process of breaking the program into various distinct features which overlaps in functionality as little as possible. ASP.Net MVC pattern concerns on separating the content from presentation and data-processing from content.

What Is The Meaning Of Unobtrusive Javascript? Explain Us By Any Practical Example?

This is a general term that conveys a general philosophy, similar to the term REST (Representational State Transfer). Unobtrusive JavaScript doesn't inter mix JavaScript code in your page markup. Eg : Instead of using events like onclick and onsubmit, the unobtrusive JavaScript attaches to elements by their ID or class based on the HTML5 data- attributes.

What Is Attribute Routing In Asp.net Mvc?

ASP.NET Web API supports this type routing. This is introduced in ASP.Net MVC5. In this type of routing, attributes are being used to define the routes. This type of routing gives more control over classic URI Routing.

Attribute Routing can be defined at controller level or at Action level like :

[Route("{action = TestCategoryList}")] - Controller Level

[Route("customers/{TestCategoryId:int:min(10)}")] - Action Level


Subscribe to get more Posts :