Explain about 'page lifecycle' of ASP.NET MVC ?

 Posted by Bharathi Cherukuri on 8/27/2012 | Category: ASP.NET MVC Interview questions | Views: 20745 | Points: 40

The page lifecycle of an ASP.NET MVC page is explained as follows:

i) App Initialisation
In this stage, the aplication starts up by running Global.asax’s 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.

ii) 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.

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

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

v) Instantiate and render view
At this stage, the IViewFactory supplies an IView, which pushes response data to the IHttpResponse object.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response