Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the operation of ASP.NET to the request processing process

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the operation of ASP.NET to the request processing process". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

When requesting a * .aspx file, the request is intercepted by the inetinfo.exe process. After it determines the suffix (aspx) of the file, it transfers the request to ASPNET_ISAPI.dll,ASPNET_ISAPI.dll and sends the request to the ASPNET_WP.exe process through the http pipeline (Http PipeLine). In the ASPNET_WP.exe process, the request is processed by HttpRuntime, and the result is returned to the client after processing.

Inetinfo.exe process: is the process of the www service, where both the IIS service and ASPNET_ISAPI.DLL are hosted.

ASPNET_ISAPI.DLL: it's processing. The win32 component of the aspx file. In fact, the IIS server can only recognize. Html file, when the IIS server finds that the requested file is. When the aspx file is created, the IIS server hands it over to aspnet_isapi.dll for processing.

Aspnet_wp.exe process: ASP.NET framework process, provided. The managed environment in which net runs. Net's CLR (common language runtime) is hosted in this process.

ASP.NET Framework handles the flow of a Http Request:

HttpRequest-- > inetinfo.exe-- > ASPNET_ISAPI.dll-- > ASPNET_WP.exe-- > HttpRuntime-- > HttpApplication Factory-- > HttpApplication-- > HttpModule-- > HttpHandler Factory-- > HttpHandler-- > HttpHandler.ProcessRequest ()

The process of ASP.NET request processing is based on the pipeline model, which is composed of multiple HttpModule and HttpHandler. ASP.NET passes the http request to each HttpModule in the pipeline in turn, and finally it is processed by HttpHandler. After the processing is completed, it goes through the HTTP module in the pipeline and returns the result to the client. We can interfere with the processing of requests in each HttpModule.

Note: during the processing of a http request, only one HttpHandler can be called, but multiple HttpModule can be called.

When the request arrives at HttpModule, the system has not really processed the request, but we can attach some other information before the request is passed to the processing center (HttpHandler), or intercept the request and do some extra work, or terminate the request, etc. After the HttpHandler has processed the request, we can reprocess the result of the request processing in the corresponding HttpModule and return it to the client.

HttpModule

The HTTP module is a class that implements the System.Web.IhttpModule interface.

Declaration of the IHttpModule interface:

Public interface IHttpModule {void Init (HttpApplication context); void Dispose ();}

Init method: called automatically when the system initializes, this method allows the HTTP module to register its own event handler with events in the HttpApplication object.

Dispose method: this method gives the HTTP module the opportunity to perform cleanup before the object is garbage collected. This method generally does not need to write code.

The HTTP module can register the following series of events with the System.Web.HttpApplication object:

AcquireRequestState raises this event when the ASP.NET runtime is ready to receive the conversation status of the current HTTP request.

AuthenticateRequest raises this event when the ASP.NET runtime is ready to authenticate the user.

AuthorizeRequest raises this event when the ASP.NET runtime is ready to authorize users to access resources.

BeginRequest raises this event when a new HTTP request is received by the ASP.NET runtime.

Disposed raises this event when the ASP.NET finishes processing the HTTP request.

This event is raised before EndRequest sends the response content to the client.

This event is raised by Error when an unhandled exception occurs during the processing of the HTTP request.

PostRequestHandlerExecute raises this event when the HTTP handler finishes execution.

PreRequestHandlerExecute raises this event before ASP.NET starts executing the handler for the HTTP request. After this event, ASP.NET forwards the request to the appropriate HTTP handler.

PreSendRequestContent raises this event before the ASP.NET sends the response content to the client. This event allows us to change the response content before it reaches 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 raises this event before ASP.NET sends the HTTP response header information to the client. This event allows us to change the contents of the header message before it reaches the client. We can use this event to add cookie and custom data to the header information.

ReleaseRequestState raises this event when the ASP.NET finishes the execution of the searched request handler.

ResolveRequestCache We raise this event to determine whether the request can be terminated with the content returned from the output buffer. This depends on how the output buffering of the Web application is set.

UpdateRequestCache raises this event when the ASP.NET has finished processing the current HTTP request and the output is ready to be added to the output buffer. This depends on how the output buffer of the Web application is set.

This is the end of the content of "what is the operation of ASP.NET to the request processing process". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report