<httpHandlers>
<add verb="*" path="*.aspx" type="MYL.SQL.MyHander,MYL.SQL"/>
</httpHandlers>
我这样是设定了整站的SQL防注入,现在需要将当中某个文件夹下的文件不执行Handler类,有什么办法吗?
<add verb="*" path="*.aspx" type="MYL.SQL.MyHander,MYL.SQL"/>
</httpHandlers>
我这样是设定了整站的SQL防注入,现在需要将当中某个文件夹下的文件不执行Handler类,有什么办法吗?
那就在你的代码获取访问页,判断是否等于你不需要执行httphandler的文件
<httpHandlers>
<add verb="*" path="*.aspx" type="MYL.SQL.MyHander,MYL.SQL"/>
<add verb="*" path="文件夹/*.aspx" type="System.Web.UI.PageHandlerFactory" />
</httpHandlers> 当添加上 <add verb="*" path="文件夹/*.aspx" type="System.Web.UI.PageHandlerFactory" /> 的时候,该文件夹中的页面就不会执行httphandler了,只是现在不知道为什么
<!--page="文件夹/*.aspx"要放在第一条,因为从上面检测下来,当遇到.aspx后缀名的都交给MyHander执行-->
<add verb="*" path="*.aspx" type="MYL.SQL.MyHander,MYL.SQL"/>
<add verb="*" path="文件夹/*.aspx" type="System.Web.UI.PageHandlerFactory" />
</httpHandlers> PageHandlerFactory 类是 ASP.NET 页的默认处理程序工厂实现,也就是文件夹/*.aspx由asp.net页默认的处理程序来执行,而不是你写的Handler执行
.NET为asp.net提供了很多系统默认HttpHandler类,用来适应不同类型的HttpRequest。比如aspx,在machine.config中是这样定义的:
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory"/>
这就说明遇到aspx的Request请求,asp.net会将其交给System.Web.UI.PageHandlerFactory的HttpHandler类来处理。
<add verb="*" path="Handler1.aspx" type="MyHandler.MyHandlerFactory, MyHandler"/>
<add verb="*" path="Handler2.aspx" type="MyHandler.MyHandlerFactory, MyHandler"/>
</httpHandlers>
到这里,针对Handler1.aspx和Handler2.aspx两个页面的http请求就通过HttpHandler工厂处理
HttpModule:如果定义了多个HttpModule,在web.config文件中引入自定义HttpModule的顺序就决定了多个自定义HttpModule在处理一个HTTP请求的接管顺序。
HttpHandler:HttpHandler与HttpModule不同,一旦定义了自己的HttpHandler类,那么它对系统的HttpHandler的关系将是“覆盖”关系.一个是按顺序处理,一个是只处理一次的.所以下面的httpHandlers配置中,path="文件夹/*.aspx"不会执行上面的注入处理.
<httpHandlers>
<add verb="*" path="*.aspx" type="MYL.SQL.MyHander,MYL.SQL"/>
<add verb="*" path="文件夹/*.aspx" type="System.Web.UI.PageHandlerFactory" />
</httpHandlers>
PS:推荐一文章
http://www.cnblogs.com/chenlulouis/archive/2009/12/18/1626918.html