1. ASP. NET Execution Process
When the clientWebThe server requests a * token process (WWW Service). After determining the file suffix, it forwards the request to aspnet_isapi.dll, while aspnet_isapi.dll uses an HTTP pipeline, send this HTTP request to the aspnet_wp.exe process. When this HTTP request enters the aspnet_wp.exe process, Asp.netFrameworkThe HTTP request is processed through httpruntime, and the result is returned to the client after processing. Itpub personal space 3Y | 6v9js
After an HTTP request is sent to httpruntime, the request will be sent to a container called httpapplication factory, the container will provide an httpapplication instance to process the passed HTTP requests, and then the HTTP requests will enter the following containers in sequence: httpmodule --> httphandler factory --> httphandleritpub personal space/V $ q'e _ % A *]! G E
After the httphandler's processrequest method in the system is processed, the entire HTTP request is processed and the client obtains the corresponding information.
Itpub personal space qhm-V ~ 3 W $ g2db ^]
Complete HTTP request processing process in Asp.net framework: itpub personal space 4e6dr; P, WS % Y
Httprequest --> inetinfo.exe-> aspnet_isapi.dll --> HTTP
Pipeline --> aspnet_wp.exe --> httpruntime --> httpapplication
Factory --> httpapplication --> httpmodule --> httphandler
Factory --> httphandler. processrequest ()Itpub personal space 'tvue #[
If you want to intercept an httprequest in the middle and perform some processing on your own, you should implement this internally during the httpruntime runtime, specifically in the httpmodule container.
II. Introduction to httpmodule
The system's httpmodule implements an ihttpmodule interface. Of course, our own class can also implement the ihttpmodule interface, which can replace the system's httpmodule object.
| Default httpmodule in xzd, b4k7i dv0asp. Net:
Defaultauthenticationmodule ensures that the authentication object exists in the context. This class cannot be inherited. Itpub personal space] * w
Olgc + vl u + d
Fileauthorizationmodule verifies that the remote user has the NT permission to access the requested file. This class cannot be inherited.
(B; z0 [/_ Q? 8j0 formsauthenticationmodule enables ASP. NET Applications to use forms authentication. This class cannot be inherited. Itpub personal space | j [} # r6a? S
The passportauthenticationmodule provides packaging for the passportauthentication service. This class cannot be inherited.
4zk0d # kf0 sessionstatemodule provides session status services for applications.
7n8ebrx 'K/ha0 urlauthorizationmodule provides URL-based authorization services to allow or deny access to specified resources. This class cannot be inherited.
* Z/6 [{J0 windowsauthenticationmodule enable ASP. NET application to use Windows/IIS authentication. Unable to inherit this class
The default httpmodule of these systems is configured in the file machine. config. the system first loads the httpmodule in machine. config from ASP. NET Framework. And the web. the Config relationship is in ASP. when the Net Framework starts to process an HTTP request, it will load the machine in sequence. the web. config file. If an httpmodule is configured in the machine, you can still. remove the ing from the config file.
Iii. Extended reading
An HTTP request is stored in ASP. NET
After the framework is captured, it is handed over to the httpmodule and httphandler for processing. HM and HH are not completely independent. In fact, HTTP requests are
In the process of HM transfer, the control is transferred to HH in an event. After the real httphandler is executed, httphandler returns the control again.
Httpmodule
The parameters in Init () of httpmodule are of the httpapplication type and have many events, including beginrequest, endrequest, and authentiacterequest.
Ihttphandler
N.] + {) ^; Pu "}, O0
It is Asp.net
An interface provided by the Framework defines some system conventions that must be implemented if an HTTP request is to be processed. That is, if you want to handle some types
For HTTP request information flows, you need to implement these system conventions. For example, a *. aspx file is used to process this type of HTTP requests, ASP. NET
Framework will be handed over to an httphandler class named system. Web. UI. pagehandlerfactory for processing.
Like hm
Framework first loads httphandler in machine. config, and then loads users in Web. config in the directory where the web application is located.
Custom httphandler class. However, the relationship between the system and our custom hh is "overwritten", that is, if we customize
For the httphandler class, the system will give the HTTP request processing permission to the httphandler class defined by us for processing, and our own
The httphandler class needs to completely parse the HTTP request and process it.
Itpub personal space/s3s + N "z q-e
The most important method in the ihttphandler interface is processrequest, which is used by httphandler to process an HTTP request.
When an HTTP request is passed to the httphandler container by the httpmodule container, the Framework calls the httphandler
The processrequest method is used to process the HTTP request. Itpub personal space z8z, {R-r7tL
The framework does not directly locate the HTTP request on the relevant page on an internal default ihttphandler container, but on its
The internal default ihttphandler factory is on. Ihttphandler
Factory is used to schedule andManagementThe advantage is that the system load is greatly enhanced and the efficiency is improved.