标签:
1. public class PageFilter : IHttpModule { public String ModuleName { get { return "PageFilter"; } } public void Dispose() { } //在 Init 方法中注册HttpApplication // 通过委托方式注册事件 public void Init(HttpApplication application) { application.AcquireRequestState += new EventHandler(Application_AcquireRequestState); } private void Application_AcquireRequestState(Object source, EventArgs e) { try { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; HttpSessionState session = context.Session; HttpRequest request = context.Request; HttpResponse response = context.Response; String contextPath = request.ApplicationPath; if (application.Context.Handler is System.Web.UI.TemplateControl) { var path = ((System.Web.UI.TemplateControl)application.Context.Handler).AppRelativeVirtualPath; } } catch (Exception ex) { throw; } } } 2.web.config <system.web> <httpModules> <add name="pageModule" type="HraWeb.PageFilter,HraWeb"/> </httpModules> </system.web> <system.webserver> <add name="pageModule" type="HraWeb.PageFilter,HraWeb"/> </system.webserver>
标签:
原文地址:http://www.cnblogs.com/kexb/p/5923359.html