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 conversation status between the HTTP module and the handler of ASP.NET

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "ASP.NET HTTP module and handler dialog state is what", in daily operation, I believe many people in ASP.NET HTTP module and handler dialog state is what kind of problem there are doubts, small make up all kinds of information, sort out simple and easy to use operation method, hope to answer "ASP.NET HTTP module and handler dialog state is what" doubts help! Next, please follow the small series to learn together!

Dialog state in HTTP handlers

Maintaining dialog state is the most common transaction performed by Web applications. HTTP handlers also need access to these dialog states. But the default setting for HTTP handlers is that no dialog state is activated. In order to read and/or write state data, HTTP handlers are required to implement one of the following interfaces:

· IRequiresSessionState

· IReadOnlySessionState.

When an HTTP handler needs to read or write dialog data, it must implement the IRequiresSessionState interface. If it reads only dialog data, implementing the IReadOnlySessionState interface will do.

Both interfaces are labeled interfaces and do not contain any methods. So, if you want to activate the dialog state of the NewHandler handler, declare the NewHandler class like this:

public class NewHandler : IHttpHandler, IRequiresSessionState

HTTP module

HTTP modules are. NET components that implement the System.Web.IhttpModule interface. These components insert themselves into the ASP.NET request processing pipeline by registering themselves in certain events. When these events occur, ASP.NET calls the HTTP module interested in the request so that the module can process the request.

The HTTP module implements the following methods of the IhttpModule interface:

Method Name Description Init This method allows HTTP modules to register their event handlers with events in the HttpApplication object. Dispose This method gives the HTTP module the opportunity to perform cleanup before objects are garbage collected.

HTTP modules can register with the following methods exposed by the System.Web.HttpApplication object:

AcquireRequestState This event is raised when the ASP.NET runtime is ready to receive the dialog state of the current HTTP request. AuthenticateRequest Raised when the ASP.NET runtime is ready to authenticate the user. AuthorizeRequest Raised when the ASP.NET runtime is ready to authorize user access to resources. BeginRequest This event is raised when the ASP.NET runtime receives a new HTTP request. Disposed This event is raised when ASP.NET completes processing an HTTP request. EndRequest Raises this event before sending the response content to the client. Error This event is raised when an unhandled exception occurs during processing of an HTTP request. PostRequestHandlerExecute Raises this event at the end of HTTP handler 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 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. such as general menu, head information or foot information. PreSendRequestHeaders Raises this event before ASP.NET sends HTTP response header information to the client. This event allows us to change the content of the header before it reaches the client. We can use this event to add cookies and custom data to header information. ReleaseRequestState Raises this event when ASP.NET ends execution of the request handler it has searched for. ResolveRequestCache We raise this event to determine whether the request can be terminated using the content returned from the output buffer. This depends on how the Web application's output buffering is set. UpdateRequestCache This event is raised when 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 buffering of the Web application is set up.

In addition to these events, we can use four more events. We can use these events by implementing some of the methods in the global.asax file of the Web application.

These events were:

· Application_OnStart

This event is raised when *** requests arrive in the Web application.

· Application_OnEnd

Raises this event before preparing to terminate the application.

· Session_OnStart

*** Requests from user conversations raise this event.

· Session_OnEnd

This event is raised when a conversation is abandoned or expired.

At this point, the study of "ASP.NET HTTP module and handler dialog state is what" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

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