IHttpHandler,IHttpModule
HttpHandler模块using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace TestHandler
{
public class TModuler : IHttpModule
{
public void Init(HttpApplication application)
{
application.BeginRequest += new EventHandler(application_BeginRequest);
}
public void application_BeginRequest(object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
context.Response.Write("<br><script>alert('测试脚本标签')</script>");
}
#region IHttpModule 成员
void IHttpModule.Dispose()
{
throw new NotImplementedException();
}
#endregion
}
}
HttpModule模块
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace TestHandler
{
public class THand :IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("这一部分是由HttpHandler添加!");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
web.config中的配置文件
<httpModules>
<add name="TModuler" type="TestHandler.TModuler" />
</httpModules>
<httpHandlers>
<add verb="*" path="*.aspx" type="TestHandler.THand"/>
</httpHandlers>
上面是一个HttpHandler模块,一个是HttpModule模块,还有web.config中的配置文件,第一次运行的时候能正常显示。此后修改输出内容,但还是显示原来的内容(项目生成成功了),哪位大牛知道是哪里出现了问题呀!版本是VS2012,IIS8.0