When an ASP. NET MVC application requests, in response to the request, contains some request execution process steps! In the ASP. HTTP request and HTTP response process, there are 8 main steps involved:
1) Creation of the routetable (routing table)
2) UrlRoutingModule request interception
3) Routing engine determine route
4) Route handler create a related IHttpHandler instance
5) IHttpHandler instance to determine controller (director)
6) Controller Execution
7) A view engine is created
8) View Rendering
The main flowchart is as follows:
1) Creation of routetable
The creation of routetable occurs when the MVC application starts or the Web application pool restarts! A typical ASP. NET program, a page request corresponds to a page on the disk! such as (http://localhost/index.aspx corresponds to the file on the server disk index.aspx) index.aspx is actually a class, created by IHttpHandler instantiation. The IHttpHandler contains a ProcessRequest method that responds to the output of a page!
But MVC application is different, each request maps to Route,route defined in the route table, which is created when the application starts!
2) UrlRoutingModule request interception
Each HTTP request is UrlRoutingModule intercepted and UrlRoutingModule provides the current HttpContext routing engine (the routing engine). The HttpContext instance contains all the data for the current request. UrlRoutingModule controls the routing engine, providing HttpContext data to routing engine! UrlRoutingModule implements the IHttpModule interface, which is registered in the Web. config file!
3) Routing engine determine route
Routing engine determines the processing of the route based on the current HttpContext. Routing engine indicates that the route table matches the route and creates the route processing in the Iroutehandler instance!
4) Route handler create a related IHttpHandler instance
In the route table, each route corresponds to a ihttphandler. IHttpHandler is responsible for creating a controller based on the current HttpContext data! IHttpHandler is created by the Gethttphandler of the currently active Iroutehandler!
5) IHttpHandler instance to determine controller (director)
In an MVC application, Mvchandler implements the Ihttphandler,controller instance, based on the input HttpContext and URL parameters corresponding to the route, Controllerfactory Create a controller,controllercontext containing the context data, passed into the controller's Excute method, triggering the controller's logical processing!
Mvchandler mainly has a controllerbuilder _controllerbuilder field;
6) Controller Execution
When all controller logic calls are executed, the actions request is executed! When the logic of the controller is executed, a actionresult is returned. A ActionResult instance, which triggers a view (view), is created and processed further when a trigger occurs.
7) A view engine is created
The instance of the view engine creates a iview interface instance that returns an Viewengineresult instance
8) View Rendering
iview Instance compilation request view that provides data for the Render method call!
"MVC" ASP. NET MVC request life cycle