Understand ASP. net mvc Execution Process

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.