37.

What is the correct order for the lifecycle of an ASP.NET MVC page

  1. 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. 
  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. 
  1. Instantiate and Execute Controller 
  • At this stage, the active IControllerFactory supplies an IController instance. 
  1. Locate and invoke controller action 
  • At this stage, the controller invokes its relevant action method, which after further processing, calls RenderView(). 
  1. Instantiate and render view 
  • At this stage, the IViewFactory supplies an IView, which pushes response data to the I