Saturday, 22 December 2018

ASP.NET MVC Execution Process / ASP.NET MVC Page Life Cycle

Requests to an ASP.NET MVC-based Web application first pass through the UrlRoutingModule object, which is an HTTP module. This module parses the request and performs route selection. The UrlRoutingModule object selects the first route object that matches the current request. If no routes match, the UrlRoutingModule object does nothing and lets the request fall back to the regular ASP.NET or IIS request processing.

First Request à UrlRoutingModule (HTTP Module ) à Check for the route à If found Route à Obtain the Route Handler (IRouteHandler) à Creates an IHttpHandler object and pass it to the IHttpContext object à MvcHandler will select the appropriate View to handle the request

Detail Explanation:
·       Receive the first request for the application
o   In the Global.asax file, Route objects are added to the RouteTable object.
·       Perform routing
o   The UrlRoutingModule module uses the first matching Route object in the RouteTable collection to create the RouteData object, which it then uses to create a RequestContext (IHttpContext) object.
·       Create MVC request handler
o   The MvcRouteHandler object creates an instance of the MvcHandler class and passes it the RequestContext instance.
·       Create a controller
o   The MvcHandler object uses the RequestContext instance to identify the IControllerFactory object (typically an instance of the DefaultControllerFactory class) to create the controller instance.
·       Execute controller - The MvcHandler instance calls the controller’s Execute method.
·       Invoke action
o   ControllerActionInvoker object that is associated with the controller determines which action method of the controller class to call, and then calls that method.
·       Execute result

  • Loads the appropriate View to the complete the request 

No comments:

Post a Comment