问题描述
我知道,如果我想为MyPage.aspx请求转到名为MyAssembly的装配MyHandler的所谓阶级,我可以将它添加到我的web.config文件:
I know that if I want to have requests for MyPage.aspx go to the class called MyHandler in the assembly called MyAssembly, I can add this to my web.config file:
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="MyPage.aspx" type="MyHandler, MyAssembly"/>
</system.web>
</configuration>
这适用于在(由)网址任何MyPage.aspx:www.mycoolsite.com/MyProject/ [SomePathHere] /MyPage.aspx
This works for any MyPage.aspx at the (made up) URL: www.mycoolsite.com/MyProject/[SomePathHere]/MyPage.aspx
如果我想这样做,每MyPage.aspx的除了的www.mycoolsite.com/MyProject/NoHandler/MyPage.aspx
What if I want to do it for every MyPage.aspx except www.mycoolsite.com/MyProject/NoHandler/MyPage.aspx
有没有办法排除从处理这条道路?
Is there a way to exclude that path from the handler?
推荐答案
您可以把它定义了一个不同的处理程序的 NoHandler
文件夹中的web.config(NOTFOUND如果你要服务器404风格等)。格式相同电流的web.config
,要覆盖类的处理器只是把唯一的元素。
You can put a web.config in the NoHandler
folder that defines a different handler (NotFound if you want to server a 404 style, etc). Same format as your current web.config
, just put only the elements you want to override like the handler.
下面是一个例子,如果你想在该目录404重写:
Here's an example if you want to override with a 404 in that directory:
<configuration>
<system.web>
<httpHandlers>
<remove verb="*" path="MyPage.aspx" type="MyHandler, MyAssembly"/>
<add verb="*" path="MyPage.aspx" type="MySpecialHandler, MyAssembly"/>
</httpHandlers>
</system.web>
</configuration>
这篇关于如何排除匹配在ASP.Net一个HttpHandler指定路径的东西呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!