To send a request to a web program based on ASP. net mvc, first passUrlroutingmoduleObject. This is an HTTP module. This module parses the request and executes the route selection.UrlroutingmoduleSelect the first route object that matches the current request. (The routing object is the implementationRoutebaseAnd is usuallyRouteClass .) If no route match exists,UrlroutingmoduleThe object does nothing, so that the request is returned to the normal ASP. NET or IIS request processing.
SelectedRouteObject,UrlroutingmoduleObject acquisitionRouteSeparatedIroutehandlerObject. In MVC programs, this is usuallyMvcroutehandler.IroutehandlerCreate an instanceIhttphandlerObject and upload itIhttpcontextObject. By defaultIhttphandlerInstance isMvchandlerObject.MvchandlerObject and then select the controller of the final processing program.
| Note:: |
| When ASP. net mvc web programs run under IIS 7.0, the MVC project does not require file name extension. However, in IIS 6.0, You need to map the. MVC file name to ASP. net isapi dll. |
Modules and processing programs are the entry points of the ASP. net mvc framework. They perform the following operations:
- Select the appropriate controller in the MVC web program.
- Obtains the specified controller instance.
- Call the Controller'sExecuteMethod.
The following table lists the stages of MVC web project execution.
| Phase |
Details |
| The first request of the receiving program |
In the global. asax file,RouteObject addedRoutetableObject. |
| Route execution) |
UrlroutingmoduleModule usageRoutetableThe first matchedRouteObject To createRoutedataObject, and then it createsRequestcontext(Ihttpcontext) Object. |
| Create an MVC request processing program |
MvcroutehandlerObject CreationMvchandlerClass and passRequestcontextInstance. |
| Create a controller |
MvchandlerObject usageRequestcontextInstance IdentificationIcontrollerfactoryObject (usuallyDefaultcontrollerfactoryTo create a controller instance. |
| Execution Controller |
MvchandlerInstance call ControllerExecuteMethod. |
| Action) |
Most controllers inherit fromControllerBase class. ThereforeControlleractioninvokerThe object determines which controller to call and call the action method. |
| Execution result |
Generally, the action method receives user input, prepares appropriate response data, and then returns the result type to execute the result. The following built-in types can be executed:Viewresult(Rendering view, the most common result type ),Redirecttorouteresult,Redirectresult,Contentresult,Jsonresult, AndEmptyresult. |
|
Address: http://www.asp.net/learn/mvc/tutorial-22-cs.aspx