首页 > 其他 > 详细

简单的过滤器

时间:2014-03-04 18:04:49      阅读:435      评论:0      收藏:0      [点我收藏+]

1  新建个类库 添加 system.web的应用

2 实现 IHttpModule的接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace FirstModule

{
class FirstModule :System.Web.IHttpModule
{

//为请求管道的第一个事件 ,也是就BeginRequest  的事件注册一个用户自动以的一个方法

public void Init(HttpApplication app)
{
app.BeginRequest += Fun; 

}
public void Fun(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
app.Context.Response.Write("每个页面前都会出现这句话");

}


public void Dispose()
{
throw new NotImplementedException();
}
}
}

 

3  在配置文件中有2种方式配置

1 在sysrem web内配置 对应iiss  集成模式

<httpModules>
<add name="first" type="FirstModule.FirstModule"/>
</httpModules>

 

2 在sysyetm web外配置 对应经典模式

<!--<system.webServer>

<modules>

<add name="first" type="FirstModule.FirstModule"/>

</modules>

</system.webServer>-->

简单的过滤器,布布扣,bubuko.com

简单的过滤器

原文:http://www.cnblogs.com/cdaq/p/3579504.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!