2012-03-19 97 views
2

我在.NET中为所有*.html文件使用自定义HttpHandler,但是我想为文件foo.html创建一个例外,应该将其作为硬件上的静态文件处理驾驶。我已经试过:IIS - 使用HttpHandler除了一个以外的所有文件

<httpHandlers> 
    <remove verb="*" path="*.html" /> 
    <add verb="*" path="/foo.html" type="System.Web.StaticFileHandler" /> 
    <add verb="*" path="*.html" validate="false" type="Imp.Handler" /> 
    </httpHandlers> 

除了:

<httpHandlers> 
    <remove verb="*" path="*.html" /> 
    <add verb="*" path="*.html" validate="false" type="Imp.Handler" /> 
    <add verb="*" path="/foo.html" type="System.Web.StaticFileHandler" /> 
    </httpHandlers> 

然而,既会造成Imp.Handler仍然处理foo.html请求。我究竟做错了什么?

IIS在经典模式下运行。

回答

0

可能是这种方法可以帮助你,将文件移动到其他文件夹并禁用此文件夹的httphandler。

<location allowOverride="false" path="Static"> 
    <system.web> 
     <httpHandlers> 
     <remove verb="*" path="*.htm"/> 
     <!--<add verb="*" path="/foo.htm" type="System.Web.StaticFileHandler" />--> 
     </httpHandlers> 
    </system.web> 
</location> 

<httpHandlers> 
    <add verb="*" path="*.html" validate="false" type="Imp.Handler" /> 
</httpHandlers> 

我想测试这一点,问题是:

if i remove HttpHandler for the "*.html" in the location element,and add a other httphandler will doesn't worked。例如:

<location> 
    <remove verb="*" path="*.htm"/> 
    <add verb="*" path="foo.html" validate="false" type="Imp.Handler" /> 
</location> 
+0

不,我需要的路径是'/ foo.html' – 2012-03-19 04:01:01

+0

OK,或者你可以使用IIS的ISAPI来解决这个问题。“Ionics Isapi Rewrite Filter” – zhengchun 2012-03-19 04:06:18

相关问题