The use of the C # filter HttpModule, as shown in the following code example:
- Using System;
- Using System.Web;
- public class Httpmodule:ihttpmodule
- {
- public void Dispose ()
- {
- }
- public void Init (HttpApplication application)
- {
- Application. Beginrequest+=new EventHandler (application_beginrequest);
- Application. Endrequest+=new EventHandler (application_endrequest);
- }
- void Application_BeginRequest (Object Source,eventargs e)
- {
- HttpApplication application= (HttpApplication) source;
- HttpContext context=application. context;
- Context. Response.Write ("Custom Module");
- }
- void Application_EndRequest (Object Source,eventargs e)
- {
- HttpApplication application= (HttpApplication) source;
- HttpContext context=application. context;
- Context. Response.Write ("Custom Module");
- }
- }
- /*
- * Configure in configuration file
- *<system.web>
- *
- *<add name= "HttpModule" type= "HttpModule"/>
- *
- *</system.web>
- */