Asp.net
如何為 Asp.Net 中的所有子文件夾註冊 HttpHandler?
我想註冊一個 HttpHandler 以包含根文件夾的所有子文件夾,無論它們嵌套多遠。我本來希望下面程式碼的行為可以做到這一點,但實際上它只包含直接在根文件夾中的項目。
<httpHandlers> <add verb="*" path="root/*" type="HandlerType, Assembly" /> </httpHandlers>我當然可以按如下方式註冊以包含第二層的任何內容,但是還沒有遇到一種方法來說出根目錄下的任何內容。
<httpHandlers> <add verb="*" path="root/*/*" type="HandlerType, Assembly" /> </httpHandlers>這是困擾我很長一段時間的事情,我很想听聽一個簡單的解決方案。
我想澄清一下,當我說“根”時,我並不是指應用程序的根,也不一定有興趣將應用程序中的所有請求發送到要處理的模組。
您不需要單獨的 web.config。在主 web.config 中使用 <location> 元素:
<!-- Configuration for the "root" subdirectory. --> <location path="root"> <system.web> <httpHandlers> <add verb="*" path="root" type="HandlerType, Assembly"/> </httpHandlers> </system.web> </location>
您可以使用 path="*" 在此“根”文件夾中創建 web.config