Dialog status in the HTTP handler
Maintaining the dialog state is the most common transaction executed by the Web application. The HTTP handler also needs to access these dialog states. However, the default settings of the HTTP handler do not activate the dialog state. To read and/or write status data, the HTTP handler must implement one of the following interfaces:
· IRequiresSessionState
· IReadOnlySessionState.
When the HTTP processing program needs to read and write the conversation data, it must implement the IRequiresSessionState interface. If it only reads the conversation data, you can implement the IReadOnlySessionState interface.
Both interfaces are labeled and do not contain any methods. Therefore, if you want to activate the dialog state of the NewHandler handler, declare the NewHandler class like the following code:
- public class NewHandler : IHttpHandler, IRequiresSessionState
HTTP Module
The HTTP module is a. NET component that implements the System. Web. IhttpModule interface. These components register themselves in some events and insert themselves into the ASP. NET Request Processing pipeline. When these events occur, ASP. NET calls the HTTP module that is interested in the request, so that the module can process the request.
The HTTP module implements the following methods for the IhttpModule interface:
Method Name |
Description |
Init |
This method allows the HTTP module to register its own event handler with the event in the HttpApplication object. |
Dispose |
This method gives the HTTP module the opportunity to clean up objects before they are collected by garbage collection. |
The HTTP module can register with the following methods exposed to the System. Web. HttpApplication object:
Event name |
Description |
AcquireRequestState |
This event is triggered when ASP. NET is ready to receive the dialog status of the current HTTP request. |
AuthenticateRequest |
This event is triggered when ASP. NET is running to verify 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 HTTP request processing. |
EndRequest |
This event is triggered before the response content is sent to the client. |
Error |
This event is triggered when an unhandled exception occurs during HTTP request processing. |
PostRequestHandlerExecute |
This event is triggered when the HTTP processing program ends. |
PreRequestHandlerExecute |
This event is triggered before ASP. NET starts executing the HTTP request processing program. After this event, ASP. NET forwards the request to an appropriate HTTP handler. |
PreSendRequestContent |
This event is triggered 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 |
This event is triggered 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 ends the execution of the searched request handler. |
ResolveRequestCache |
This event is triggered 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. |
In addition to these events, we can also use four events. We can use these events by implementing some methods in the global. asax file of Web applications.
These events are:
· Application_OnStart
This event is triggered when the first request reaches the Web application.
· Application_OnEnd
This event is triggered before the application is terminated.
· Session_OnStart
This event is triggered by the first request of the user conversation.
· Session_OnEnd
This event is triggered when the conversation is abandoned or the conversation is out of date.
- HTTP module and processing program of ASP. NET
- HTTP module of ASP. NET and request handling process of processing programs
- Execution of the HTTP module and processing program of ASP. NET
- Registration and use of the HTTP module of ASP. NET and the HTTP module of the processing program
- ASP. net http module and processing program module implementation