1.1 Basic concepts of ASP. NET-HTTP runtime and page execution model

Source: Internet
Author: User

HTTPRuntime and page execution model

-- Learning ASP. NET

Wenye: August 8, 2006 Tuesday

 

HTTPRuntime

During the HTTP runtime, a Web request is sent to a client application (such as a Web browser), and requests are routed by appropriate components of the application, then the client application that responds to the concurrent request is generated.

The HTTP Web request is first received by the IIS Web server. The request is sent to the ASP. net isapi Based on the ASP. NET registered extension.

During the HTTP runtime, an instance of the HttpContext object is first created, which contains the request information currently being processed, and then a context object that can be used by all other components involved in the processing logic is created. The HttpContext instance provides access to the request object (HttpRequest class instance) and response object (HttpResponse class instance.

HTTP runtime integration is a processing pipeline composed of components called HTTP Module, used to execute Request preprocessing actions (such as cache query and authorization) and post-processing actions (such: update and adjust cache ). These components implement the IHttpModule interface. In the pipeline, each module processes different global application layers and specific request events to execute its logic.

During the HTTP runtime, the request-based URL also selects an HTTP Processing Program (Component implementing the IHttpHandler Interface) or an HTTP processing program Factory (Component implementing the IHttpHandlerFactory Interface) to complete the actual processing process of the request. The handler uses the HttpContext object to collect request information and write the response results.



Figure 1 request processing in ASP. NET Web applications

 

OneHTTPRequest Processing Process

After an HTTP request is sent to HttpRuntime, the request is sent to a container called HttpApplicationFactory. In this window, an HttpApplication instance is provided to process the passed HTTP request, and then the HTTP request enters the following containers in sequence:

HttpModule --> HttpHandler Factory --> HttpHandler

After the ProcessResquest method of HttpHandler in the system is processed, the entire Http Request is processed and the client gets the corresponding result.

 

The process of processing a complete HTTP request in ASP. NET Framework is as follows:

HttpRequest --> inetinfo.exe --> response --> Http Pipeline --> ASPNET_WP.exe --> HttpRuntime --> HttpApplication Factory --> HttpApplication --> HttpModule --> HttpHandler Factory --> HttpHandler. processRequest ()

 

Page execution model

The page execution model starts from the page HTTP handler factory. It registers the HTTP runtime to process requests for all. aspx files. The Page handler factory is responsible for creating an instance of a Page object, which is an HTTP processing program that will eventually process the response results generated by the request.

First, the page handler factory tries to find the previously compiled page class in the. NET cache related to the requested. aspx file. When the search fails, like the first request, the handler factory will read and parse the file and create a parse tree ). The resolution tree is similar to the control tree, but does not contain controls. The resolution tree contains an object instance called control builder. The control builder contains the control information collected during the parsing process. Then, use the Language attribute in the Page command to convert the parsing tree into code in the Language related to the Page. Then, the Page handler factory calls the appropriate Compilation Program to dynamically compile the class obtained from the Page. The Page handler factory also places the newly created class to ASP.. NET adjusts the cache and associates the cache records with the file relevance. File relevance monitoring. changes made by the aspx file, and ensures that any changes will automatically invalidate the cache record. In the next request, these records will parse the modified files again.


Figure 2: how to process requests on a page

References
ASP. NET Server Control and component development
In-depth analysis of ASP. NET

Next article:1.1 learning basic concepts of ASP. NET -- HttpModule

Related Article

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.