ASP.NET Web page life one day

xiaoxiao2021-03-06  57

ASP.NET Web page life one day

Introduction

Each request for Microsoft® Internet Information Services (IIS) processing will be handed over to ASP.NET HTTP pipes. The HTTP pipe is composed of a series of managed objects, and these managed objects handle requests in order and convert the URL to pure HTML text. The entrance to the HTTP pipe is an HTTPRuntime class. The ASP.NET structure creates a such instance of each appdomain in the auxiliary process. (Note that the auxiliary process maintains a specific Appdomain for each currently running ASP.NET application.)

The HTTPRuntime class gets the HTTPApplication object from the internal pool and schedule this object to handle the request. The main task completed by the HTTP application manager is to find classes that will truly process the request. When requesting .ASPX resources, the handler is a page handler, an instance of a class inherited from page. The association between the resource type and the handler type is stored in the application's configuration file. More specifically, the default mapping set is defined in the part of the machine.config file. However, the application can customize your own HTTP handler list in the local web.config file. The following line code is used to define the HTTP handler for the .aspx resource.

The extension can be associated with the processing program class, and more is associated with the processing program factory class. In all cases, the HTTPApplication object that is responsible for processing the request will get an object that implements the IHTTPHANDLER interface. If the associated resource / class is parsed according to the HTTP handler, the returned class will directly implement the interface. Additional steps are required if resources are bind to the processing program. Handling the program factory class implements the IHTTPHANDLERFAACTORY interface. This interface will return an object based on IHTTPHANDLER.

How is HTTP runtime end this loop and handles page requests? The ProcessRequest method is very important in the IHTTPHANDLER interface. This method is called by the object that represents the requested page, the ASP.NET structure starts the process that will generate a browser output.

Real Page class

The HTTP handler type of a particular page depends on the URL. When you first call the URL, a new class will be built, which is dynamically compiled into an assembly. Check the result of the analysis process of the .aspx resource is the source code of the class. This class is defined as an integral part of the namespace ASP and is given a name that simulates the original URL. For example, if the endpoint of the URL is Page.ASPX, the name of the class is ASP.PAGE_ASPX. However, the name of the class can be controlled by programming, and the method is set in the @PAGE instructions to set the className property.

The base class of the HTTP handler is Page. This class defines the minimum collection of methods and properties shared by all page handles. Page class implements the IHTTPHANDLER interface.

In many cases, the base class of the actual handler is not Page, but other classes. For example, this happens if code separation is used. Code Separation is a development technology that isolates the code required by the page to a separate C # and Microsoft Visual Basic® .NET class. The code of the page is a set of event handlers and auxiliary methods, which truly determines the behavior of the page. You can use the