Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to register HttpHandler for all subfolders in Asp.Net?

I would like to register an HttpHandler to include all subfolders of a root folder regardless of how far down they are nested. I would have expected the behavior with the below code to do just that but in fact it only includes items directly in the root folder.

<httpHandlers>
  <add verb="*" path="root/*" type="HandlerType, Assembly" />
</httpHandlers>

I can of course register as below to include anything that is second tier, however have yet to encounter a way to just say anything below root.

<httpHandlers>
  <add verb="*" path="root/*/*" type="HandlerType, Assembly" />
</httpHandlers>

This is something hat has been bugging me for quite a while and I would love to hear of a simple solution.

I would like to clarify that when I say "root" I do not mean the root of the application and am not necessarily interested in sending all requests in the application to a module to be processed.

like image 805
YonahW Avatar asked Apr 02 '09 18:04

YonahW


1 Answers

You don't need a separate web.config. Use the <location> element in your primary web.config:

<!-- Configuration for the "root" subdirectory. -->
<location path="root">
  <system.web>
    <httpHandlers>
      <add verb="*" path="root" type="HandlerType, Assembly"/>
    </httpHandlers>
  </system.web>
</location>
like image 148
Kevin P. Rice Avatar answered Oct 20 '22 00:10

Kevin P. Rice