IHttpModule过滤htm文件时会出现,只过滤一遍的情况,当第二次提交时会不会进行过滤,直接出现静态画面,解决的办法是在IHttpModule过滤时,过滤结束时要用命令让页面跳转.但是aspx页面就不需要用命令跳转,程序会自动执行下去.如果用命令显示跳转的话,aspx页面的控件事件就不会触发了,那样只能显示动态页面,而无法执行页面的代码了.
public void Init(HttpApplication application){ application.AcquireRequestState += (new EventHandler(this.Application_AcquireRequestState)); } private void Application_AcquireRequestState(Object source, EventArgs e) { HttpApplication Application = (HttpApplication)source; //User user=Application.Context.Sesseion["User"] //获取User string url = Application.Context.Request.Path; HttpResponse response = Application.Context.Response; if(url.IndexOf("abc") > -1) ){ if(url.IndexOf("abc") > -1) { response.write("this is html"); response.Redirect(url); }} else { if(url.IndexOf("abc") > -1) {response.Redirect(url); } }
不知道理解的是否有问题,呵呵.