ASP. NET MVC Calf Tour 4:asp.net MVC running life cycle

Source: Internet
Author: User

The operating life cycle of ASP is broadly divided into three main processes:(1) URL routing comparison. (2) Run Controller and action. (3) Run the View and return the result.

4.1 URL Routing Comparison

When IIS receives an HTTP request, all operations related to URL routing are handled first through the urlroutingmodule module. By default, if the URL can correspond to an entity document that is relative to the root of the Web site, it will not be processed through ASP. NET MVC, and will automatically bypass all URL routing comparisons, but instead directly to IIS or ASP.

If you want to change the default contrast behavior of this urlroutingmodule , let all HTTP requests sent from the client browser to IIS go through the urlroutingmodule module to determine the routing rules. You can RouteTable.Routes.RouteExistingFiles = True at the front of the Application_Start () event of the Global.asax. :

After Setup, all incoming HTTP requests for the site will be one by one compared to the URL routing rules defined in registerroutes , and if the comparison succeeds, it will be handled with ASP. NET MVC behavior. The default is given to Mvchandler to run , and if it fails, the opportunity will run the power of handing over to IIS.

4.2 Running the Controller and action

When the program runs to Mvchandler , we know that all HttpHandler Run entry points are ProcessRequest methods that run the Controller The Execute () method , which is then run to the Executecode () method, determines which action in the controller is run by the route value, If the action can run when not found from the controller category, the handleunknownaction is run

method, there is a type that inherits from ActionResult called Viewresult, if the action callback type is Viewresult, there will be the next section of the process to execute, not run return View () when the end, Otherwise, it will run the result and respond to the client by actually inheriting the object from ActionResult.

4.3 Run view and return results

If the ActionResult object returned from the action is Viewresult, ASP. NET MVC will further invoke the Findview method of the object entity that implemented the Iviewengine interface. To obtain an object entity that takes a iview interface, and then calls the Ivew object entity's render () method to respond to the HTML to the client.

4.4MVC Execution Steps Overview diagram

ASP. NET MVC Calf Tour 4:asp.net MVC running life cycle

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.