asp.net Request Response Process Overview _ Practical skills

Source: Internet
Author: User

First, the browser request the simple process of the page

When the browser requests a static page, will send the request to the server software, the server software directly to find the corresponding static page, and return to the browser.

When the browser requests the dynamic page, the server software receives the request, discovers cannot handle the. aspx file, goes to the mapping table according to the suffix name to find the corresponding processing program (aspnet_ Isapi.dll), this handler implements the interface provided by the server software, that is, the server software calls the method of the handler through the interface. Aspnet_isapi.dll will pass the request to the. Net Framework, which handles dynamic pages, creates page objects, generates corresponding messages, and responds to browsers.

When the server receives the browser's dynamic page request, goes to the website's assembly to find the corresponding class, creates the class object by the reflection way, and runs the ProcessRequest method to handle the user's demand, finally through the Write method output the response data.

When you execute write, you put the data in a buffer and return it to the browser at once after the page has finished executing.

the IHttpHandler of the two or one-like processing program Interface

The server receives the request, to create a Page object, it is found that each file is a class that does not know how to invoke the method creation page, and therefore requires an intermediate processing--the object of the page class into an interface IHttpHandler type, and then implements the processing by calling the method in the interface.

The general handler is a class that implements the IHttpHandler special interface, and any class that implements this interface can be used as an external request target program.

If the requested class does not implement this interface, an error occurs at the time of conversion, prompting that the IHttpHandler interface is not implemented. So, the method in the general processing program, actually realizes the method in the IHttpHandler.

Details of general processing procedures

IHttpHandler is an important interface that encapsulates the request messages from all browsers, and the ProcessRequest method indicates that the code snippet in this method is called when the page is accessed, and is an entry. Context.response is the encapsulation of the output, ContextType is the ContextType value in the response message, and is the way of responding to the output.

IsReusable is another method in IHttpHandler to set whether a page can be reused to reduce the pressure on the Web server when multiple accesses are made.

Four, detailed request process

The server receives a user request and aspnet_isapi.dll the request to application Domain, which indirectly invokes the HttpRuntime static method to process the user's request.

First, the request message is analyzed and the request message is encapsulated into a HttpWorkerRequest object, then the request message is disassembled, and each field encapsulates the bit HttpRequest object (This object contains the QueryString and form methods).

HttpRequest objects and HttpResponse objects, and so on, together constitute the HttpContext object.

HttpApplicationFactory class to find out if there are any available HttpApplication objects in the application pool, if so, just use them directly, and if not, create one. There are ProcessRequest methods in the HttpApplication object, this method has HttpContext object. Just take it from here.

The HttpApplication object enters the request pipeline, executes 19 delegate events, creates the object of the requested page at the 8th event, and executes the ProcessRequest method of the created object between the 11th and 12 events.

Five, WebForm the page life cycle

After the 11th event of the request pipeline executes the Peocessrequest method of the Created page class, the Buildcontrolstree method is invoked to enter the life cycle of the page.

A succession of events are invoked in the page lifecycle, where one render method traverses the entire control tree, generates the corresponding HTML code, and finally returns the HTML code of the entire page back to the browser.

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.