Developers should learn more about the theoretical layer of IIS ~ 4. Major Events in httpmodel

Source: Internet
Author: User

Returned directory

This article mainly introduces httpmodule. We need to know the process of a webpage request. We also need to know when the httpmodule is executed during webpage loading, in addition, we need to know the events triggered by httpmodule during the webpage request process. Let's take a look at the article with questions below.

Process of ASP. NET processing requests

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 (otherwise, it will be explained to the corresponding application ), 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, and the result is returned to the client after processing.

The following describes the meaning of each term.

Inetinfo.exe process:Is the WWW Service Process, 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:The ASP. NET Framework process provides a managed environment for. Net Running. the. net clr (Common Language Runtime) is stored in this process.

Aspnet_wpProcess an HTTP request

Httprequest -->

Inetinfo.exe -->

Aspnet_isapi.dll -->

Aspnet_wp.exe -->

Httpruntime -->

Httpapplication factory -->

Httpapplication -->

Httpmodule -->

Httphandler factory -->

Httphandler -->

Httphandler. processrequest ()

In the above process, we can see when the httpmodel was executed.
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.

Httpmodule registers the following events

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.

Well, with the basic knowledge above, I believe you have a new understanding of httpmodule.

Returned directory

Developers should learn more about the theoretical layer of IIS ~ 4. Major Events in httpmodel

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.