Datamatics Asp.net Mvc Interview Questions

Datamatics Most Frequently Asked ASP.NET MVC Interview Questions Answers

What Is The Use .glimpse In Asp.net Mvc?

Glimpse is an open source tool for debugging the routes in ASP.Net MVC. It is the client side debugger. Glimpse has to be turned on by visiting to local url link - http://localhost:portname//glimpse.axd This is a popular and useful tool for debugging which tracks the speed details, url details etc.

What Are Model Binders In Asp.net Mvc?

For Model Binding we will use class called : "ModelBinders", which gives access to all the model binders in an application. We can create a custom model binders by inheriting "IModelBinder".

How We Can Handle The Exception At Controller Level In Asp.net Mvc?

Exception Handling is made simple in ASP.Net MVC and it can be done by just overriding "OnException" and set the result property of the filtercontext object (as shown below) to the view detail, which is to be returned in case of exception.

protected overrides void OnException(ExceptionContext filterContext)

    {

    }

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();

}
Datamatics Most Frequently Asked ASP.NET MVC Interview Questions Answers
Datamatics Most Frequently Asked ASP.NET MVC Interview Questions 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 The Advantages Of Dependency Injection (di) In Asp.net Mvc?

Below are the advantages of DI

Reduces class coupling
Increases code reusing
Improves code maintainability
Improves application testing

Does Tempdata Hold The Data For Other Request In Asp.net Mvc?

If Tempdata is assigned in the current request then it will be available for the current request and the subsequent request and it depends whether data in TempData read or not. If data in Tempdata is read then it would not be available for the subsequent requests.

Explain Keep Method In Tempdata In Asp.net Mvc?

As explained above in case data in Tempdata has been read in current request only then "Keep" method has been used to make it available for the subsequent request.

@TempData["TestData"];

TempData.Keep("TestData");

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();

What Is Area In Asp.net Mvc?

Area is used to store the details of the modules of our project. This is really helpful for big applications, where controllers, views and models are all in main controller, view and model folders and it is very difficult to manage.

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();

}

What Are Child Actions In Asp.net Mvc?

To create reusable widgets child actions are used and this will be embedded into the parent views. In ASP.Net MVC Partial views are used to have reusability in the application. Child action mainly returns the partial views.

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 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" });

}

Post a Comment

Previous Post Next Post