In ASP. NET,
Two modules are embedded in the browser:
Socket communication module → the browser puts the data in the address bar and its data into the http request header file, and the Socket sends the http request data to the remote server
Browser Engine rendering module → the browser accepts the http response header data returned from the server and the user request data to render the data into the user's visible interface
ASP. NET developers and HttpApplication, HttpContext, HttpRequest, and HttpResponse should be old acquaintances, while ASP. NET event pipeline is also ASP. NET programmers are familiar with it. As far as the author is concerned, it has always been a bit difficult for these programmers, even though many documents are still the case. In fact, these classes are created after the asp.net Server accepts browser requests. ASP. NET servers process and respond to browser requests using these four classes (mainly these four classes.
The HttpRuntime class is the entry for processing ASP. NET servers. The above four classes are created based on this class. The HttpRuntime class creates these four classes respectively to help it process browser requests. The following describes the four categories:
HttpRequest class. Many of these attributes represent the parameters of the Http request.
HttpResponse class, which provides methods and attributes to respond to the client.
HttpContext class, which encapsulates the HttpRequest class and HttpResponse class objects, mainly to simplify the processing of HTTP parameters on the server side.
The HttpApplication class is the most important thing. This class is used to process requests. The pipeline we call is created here. Because in the actual request processing process, we need to do a lot of work. If we complete these tasks in one method, it will obviously cause excessive bloated methods. In HttpApplication, the. NET event mechanism is used to separate the handling process into multiple steps by sending multiple events in the processing process. This is the processing pipeline.
In the ProcessRequest event of the event pipeline, the input parameter is an instance of the HttpContext class, because in this method, we process the HTTP request in detail, and we need to obtain detailed information, the HttpContext class instance is passed in.
The general running process is as follows:
The data and figures in this article are from the Black Horse programmer. net Video and ASP. NET essence.