How do I exclude things that match the specified path for an HttpHandler in ASP.Net?

后端 未结 1 964
天命终不由人
天命终不由人 2021-01-21 04:21

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:

         


        
相关标签:
1条回答
  • 2021-01-21 04:42

    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.

    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>
    
    0 讨论(0)
提交回复
热议问题