using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
/// <summary>
///Class1 的摘要说明
namespace MyModule
{
public class MyModule : IHttpModule
{
/// <summary>
/// 初始化加入两个事件到Application 里面去.
/// </summary>
/// <param name="application"></param>
public void Init(HttpApplication application)
{
application.BeginRequest += (new
EventHandler(this.Application_BeginRequest));
application.EndRequest += (new
EventHandler(this.Application_EndRequest));
}
///在这里必须相当于是把Response转过来。在这里根本直接用不了。不知道为啥。
///写这个的作用是进行权限判断。
private void Application_BeginRequest(Object source, EventArgs e)
{
HttpApplication Application = (HttpApplication)source;
HttpResponse ResponseOK = Application.Context.Response;
ResponseOK.Write("<h1>Beginning of Request</h1><hr>");
}
private void Application_EndRequest(Object source, EventArgs e)
{
HttpApplication Application = (HttpApplication)source;
HttpResponse ResponseOK = Application.Context.Response;
ResponseOK.Write("<h1>End of Request</h1><hr>");
}
public void Dispose() { }
}
}
////下面是Web.Config 里面的
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add name="MyModule" type="MyModule.MyModule"/>
<!--<add name="MyModule" type=""/>-->
</httpModules>
///这样每执行个页面会调用这个方法。