在web.config中的配置
<httpModules>
<add name="myModule" type="MyWeb.MyModule" />
</httpModules>可以在配置文件中加只拦截*.aspx的限制吗??
还是只可以在MyModule中处理????? private void context_AcquireRequestState(object sender, EventArgs e)
{
HttpApplication application = sender as HttpApplication;
HttpRequest request = application.Request;
HttpResponse response = application.Response; string uri = request.RawUrl; string a= uri.Substring(uri.LastIndexOf(".") + 1); //只拦截aspx页面
if (a.Contains("aspx"))
{
//处理
}
}
<httpModules>
<add name="myModule" type="MyWeb.MyModule" />
</httpModules>可以在配置文件中加只拦截*.aspx的限制吗??
还是只可以在MyModule中处理????? private void context_AcquireRequestState(object sender, EventArgs e)
{
HttpApplication application = sender as HttpApplication;
HttpRequest request = application.Request;
HttpResponse response = application.Response; string uri = request.RawUrl; string a= uri.Substring(uri.LastIndexOf(".") + 1); //只拦截aspx页面
if (a.Contains("aspx"))
{
//处理
}
}
httphandle负责处理
如果要过来aspx页面,要用httpmodule
{
string FileName = context.Server.MapPath(context.Request.FilePath);
if (context.Request.UrlReferrer.Host == null){}
else
{
if (context.Request.UrlReferrer.Host.Contains(""))
{
}
}
}
public bool IsReusable
{
get { return true; }
}
如果是1.aspx上的图片 *.jpg,链接a.htm。触发的时候都会被过滤如何屏蔽?
<add name="myModule" path="*.aspx" type="MyWeb.MyModule" />
</httpModules>
*.jpg等这些文件默认由iis直接处理,用不着使用自定义httpmodule过滤。如果使用vs内置web服务器,则所有请求都会经过所有的httpmodule由aspnet_isapi.dll处理。
它没有path属性,硬写会报错!
它没有path属性,硬写会报错!