Using System;
Using System. Web;
Using System. Web. sessionstate;
Namespace Httpmodulename
{
Public Class Moduleclass: ihttpmodule
{
Public Void Init (httpapplication Application)
{
Note: Asp.net occurs when httphandlers is executed (for example, when a user requests the XXX. aspx, XXX. asmx page)
Application. prerequesthandlerexecute+ = NewEventhandler (This. Application_prerequesthandlerexecute );
}
Private Void Application_prerequesthandlerexecute (Object source, eventargs E)
{
Execute the operation you want ..... (I am generally used for page permission Control)
}
}
}
Added the configuration of httpmodules in webconfig.
<Httpmodules>
<Add name = "cookiemodule" type = "httpmodulename. moduleclass, moduleclass"/>
</Httpmodules>
The configuration file is described as follows:
<Httpmodules>
<Add type = "type" name = "name"/>
</Httpmodules>
Type Value provides the HTTP module's Program Set and class name, while
Name The value provides a friendly name. You can use this friendly name in the global. asax file to reference the HTTP module.