When a * .aspxfile is requested, the request will be intercepted by the inetinfo.exe process. After determining the file suffix (aspx), it will forward the request to aspnet_isapi.dll, aspnet_isapi.dll sends the request to aspnet_wp.exein the HTTP pipeline. The request is processed through httpruntime in the aspnet_wp.exe process. After the request is processed, the result is returned to the client.
Inetinfo.exe process: the process of WWW Service. Both IIS service and aspnet_isapi.dll are stored in this process.
Aspnet_isapi.dll: A Win32 component used to process the. aspx file. The iisserver can only identify the .html file. When the IIS server finds that the requested file is a. aspx file, the IIS server submits it to aspnet_isapi.dll for processing.
Aspnet_wp.exe process: an ASP. NET Framework process that provides a managed environment for. Net Running. the. net clr (runtime in public language) is stored in this process.
ASP. NET Framework processes an HTTP request:
Httprequest --> inetinfo.exe --> response --> aspnet_wp.exe --> httpruntime --> httpapplication factory --> httpapplication --> httpmodule --> httphandler factory --> httphandler. processrequest ()
ASP. the net request processing process is based on the pipeline model, which consists of multiple httpmodules and httphandler, Asp.. Net passes the HTTP request to each httpmodule in the pipeline in sequence, and is finally processed by httphandler. After the processing is completed, it passes through the HTTP module in the pipeline again and returns the result to the client. We can intervene in the request processing process in each httpmodule.
Note: During HTTP request processing, only one httphandler can be called, but multiple httpmodules can be called.
When the request arrives at httpmodule, the system has not actually processed the request, but we can add some other information before the request is passed to the processing center (httphandler, or intercept the request and do some additional work, or terminate the request. After httphandler finishes processing the request, we can re-process the request processing result in the corresponding httpmodule and return it to the client.
Httpmodule
The HTTP module is a class that implements the system. Web. ihttpmodule interface.
Ihttpmodule interface declaration:
Public interface ihttpmodule
{
Void Init (httpapplication context );
Void dispose ();
}
Init method: automatically called during system initialization. This method allows the HTTP module to register its own event processing with the event in the httpapplication object.Program.
Dispose method: This method gives the HTTP module the opportunity to clean up objects before they are collected by garbage collection. This method is generally not requiredCode.
The HTTP module registers the following events with the system. Web. httpapplication object:
Acquirerequeststate this event is triggered when ASP. NET is ready to receive the current HTTP request dialog state.
Authenticaterequest this event is triggered when ASP. NET is running to authenticate the user identity.
Authorizerequest this event is triggered when ASP. NET is ready to authorize users to access resources.
Beginrequest this event is triggered when ASP. NET receives a new HTTP request.
Disposed this event is triggered when ASP. NET completes the HTTP request processing process.
This event is triggered before the endrequest sends the response content to the client.
An error occurs when an unhandled exception occurs during HTTP request processing.
Postrequesthandlerexecute triggers this event when the HTTP processing program ends.
Prerequesthandlerexecute raises this event before ASP. NET starts executing the HTTP request processing program. After this event, ASP. NET forwards the request to an appropriate HTTP handler.
Presendrequestcontent triggers this event before ASP. NET sends the response content to the client. This event allows us to change the response content before the content arrives at the client. We can use this event to add content for all pages to the page output. For example, general menu, header information, or foot information.
Presendrequestheaders triggers this event before ASP. NET sends the HTTP response header information to the client. Before the header information arrives at the client, this event allows us to change its content. We can use this event to add cookies and custom data to the header information.
Releaserequeststate this event is triggered when ASP. NET finishes executing the searched request processing program.
Resolverequestcache triggers this event to determine whether the request can end with the content returned from the output buffer. This depends on how to set the web application output buffer.
Updaterequestcache this event is triggered when ASP. NET processes the current HTTP request and the output content is ready to be added to the output buffer. This depends on how the web application's output buffer is set.