Process description of the request processing response on the asp.net page

Source: Internet
Author: User

Process description of the request processing response on the asp.net page
Overview

This blog post is running from IIS to the asp.net page. The whole process is described in a simple way. If there is anything wrong, I hope to point it out.

Process of IIS processing requests

When we access a webpage on an IIS server through a browser (Socket Client), the request arrives at the IIS server, the http of IIS. the sys (distributor) component will hand over it to the corresponding application pool based on the corresponding judgment (the corresponding registration information is available on IIS ), after a request is received by the corresponding application pool, it is handed over to the corresponding Working Process for processing. After receiving the request, the working process determines Based on the suffix of the request file, if the IIS File can be processed, it will be processed directly. If it cannot be processed, search for the plug-in (asp.net _ isapi) that can process the request from the plug-in configuration file it registered. dll, or php plug-ins), and give it to the plug-in (proxy), then the plug-in will send the request to the real processing program.

Browser

From a program perspective, the browser is a Socket client, and IIS is a Socket server to implement the communication function. For the above, we can use Telnet (Socket Client, win comes with the installation program, you need to install it yourself) for verification. Input telnet 127.0.0.1 80 in cmd to connect to the server and then send a request, you will get a response,

Asp.net _ isapi. dll plugin

The plug-in mechanism of IIS enables IIS to serve websites in any language. As long as it registers corresponding plug-ins on IIS, IIS can process requests for such files, for example, if you want to use IIS for php services, you only need to register the php plug-in. This idea is very powerful, which greatly improves the scalability of IIS. Of course, this plug-in is not a program that processes requests, but a proxy. Through this proxy (the content written in the IIS configuration file during registration), IIS can know that it can process such files, in addition, through this proxy, the request can be handed over to the real program for processing. Of course, the returned results are also returned through this.

We can view the files that can be processed in the handler ing on the IIS server. If you install VS first and then IIS, if you want your IIS to process the corresponding files of asp.net, You need to manually set asp.net _ isapi. dll is registered in IIS. In the cmd-directory, locate the specific version installed on the local machine. net framework (there is the aspnet_regiis.exeprogram running-run aspnet_regiis.exe-I

. Net framework HTTP Pipeline mechanism

After receiving the request, asp.net _ ispai. dall handed it to. net framework, and then began to implement the http Pipeline mechanism.

. Net framework receives a request, instantiates the HttpRuntime object, and calls the ProcessRequest method. Then, it instantiates the Application object through HttpApplicationFacotry. During the instantiation process, it will continue to instantiate the httpContext, HttpRequest, HttpResponse, Module, and so on, then, the instance of the IHttpHandler interface is instantiated.

If you pay attention to it, our asp.net page is an implementer of the IHttpHandler interface. The asp.net page inherits the page class and the page class inherits the IHttpHandler interface, in this way, our asp.net page can access the objects instantiated above. In addition, The Golbal file inherits the HttpApplication file, so that we can write the methods in Golbal to register events in the Http pipeline.

Asp.net page Lifecycle

Instantiating an IHttpHandler interface instance is actually a page that instantiates asp.net. The process of instantiating an asp.net page mainly goes through these events, such as initialization, loading, control events, saving state, rendering, and uninstallation. Here we need to know that the control event is executed on the page. Before pre-rendering, after loading, of course, there will be no control event triggered during the first time. In the initialization phase, create the control tree and assign values to corresponding properties. Therefore, do not operate on the control attribute values during this phase. Because there is no value, during the loading process, we can perform corresponding operations on the control. If you want to perform operations in preload Before loading.

Summary

During the process of text description, I found that I did not know the description. When I described it, I noticed that I did not think about the entire process carefully. Then, I checked the information again, I wrote these things, hoping to be interested in the readers. I also suggest you read some other materials to deepen your understanding.

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.