AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Thursday 10 March 2016 MVC interview questions for experienced

In this blog post I have given some important interview questions for experienced candidates. Please read below questions with explanation.
Question 1- Advantages of MVC over ASP.NET?

  • Provides a clean separation of concerns among User Interface(Presentation layer), model (Entities) and Business Logic(Controller). 
  • Improved structuring of the code.
  • Easy to UNIT Test.
  • Improved re-usability of model and views. 
Question 2- Explain the page life cycle of MVC?

1- App Initialization
In this stage, the application starts up by running Global.asax Application_Start() method.
In this method, you can add Route objects to the static RouteTable.Routes collection.
If you’re implementing a custom IControllerFactory, you can set this as the active controller factory by assigning it to the System.Web.Mvc.ControllerFactory.Instance property.

2- Routing
Routing is a stand-alone component that matches incoming requests to IHttpHandlers by URL pattern.
MvcHandler is, itself, an IHttpHandler, which acts as a kind of proxy to other IHttpHandlers configured in the Routes table.

3- Instantiate and Execute Controller
At this stage, the active IControllerFactory supplies an IController instance.

4- Locate and invoke controller action
At this stage, the controller invokes its relevant action method, which after further processing, calls RenderView().

5- Instantiate and render view

At this stage, the IViewFactory supplies an IView, which pushes response data to the IHttpResponse object.

Question 3- Return types of a controller action method ?
Read article

Question 4- Difference between ViewBag, ViewData, and ViewDataDictionary in MVC
Read article

Question 5-Explain about Repository pattern?
Read article

Question 6- What are the advantages of using mvc ?
The main advantages of using mvc are as follows:
i) One of the main advantage is that it will be easier to manage the complexity as the application is divided into model,view and controller.
ii) It gives us the full control over the behavior of an application as it does not use view state or server-based forms.
iii) It provides better support for test-driven development (TDD).

iv) You can design the application with a rich routing infrastructure as it uses a Front Controller pattern that processes Web application requests through a single controller.

Question 8- Explain about the formation of Router Table in ASP.NET MVC ?
The Router Table is formed by following the below procedure:

In the begining stage, when the ASP.NET application starts, the method known as Application_Start() method is called.
The Application_Start() will then calls RegisterRoutes() method.
This RegisterRoutes() method will create the Router table.

Question 9- 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

Question 10- Explain Dependency Resolution?
Dependency Resolver again has been introduced in ASP.Net MVC3 and it is greatly simplified the use of dependency injection in your applications. This turn to be easier and useful for decoupling the application components and making them easier to test and more configurable.


Post a Comment

  • Popular Posts
  • Comments