日期:2010-01-01 浏览次数:20534 次
C#过滤器HttpModule的使用,如下代码示例:
- 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("自定义模块");
 - }
 - void Application_EndRequest(Object source,EventArgs e)
 - {
 - HttpApplication application=(HttpApplication)source;
 - HttpContext context=application.Context;
 - context.Response.Write("自定义模块");
 - }
 - }
 - /*
 - * 在配置文件中配置
 - *<system.web>
 - *<httpModule>
 - *<add name="HttpModule" type="HttpModule"/>
 - *</httpModule>
 - *</system.web>
 - */