我使用的是Asp.Net 4 C#和IIS 7.5。
在web.config中我能够成功应用我的处理程序(下面的代码),因为你可以看到path="*.jpg"
让处理程序在我网站的任何文件夹中运行。
我需要在我的案例to all .jpg request but ONLY in a specific folder
/Cdn/Cms/Images/
所以我更新到path="/Cdn/Cms/Images/*.jpg"
,但处理程序不适用。
我尝试了多次不同的路径但是现在。
如何将处理程序仅应用于特定文件夹?
感谢您抽出宝贵时间。
此问题与this one
有关 <system.webServer>
...
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="Cms-ImageRouteHandler" path="*.jpg" verb="*" type="WebProject.Cms.BusinessLogics.SEO.Routing.ImageRouteHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode" />
</handlers>
...
答案 0 :(得分:3)
尝试在您的网站文件夹中创建/Cdn/Cms/images
文件夹结构,然后在该文件夹中创建一个web.config,其中包含以下内容:
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="Cms-ImageRouteHandler" path="*.jpg" verb="*" type="WebProject.Cms.BusinessLogics.SEO.Routing.ImageRouteHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>
然后,您可以从主站点的web.config中删除它。看看是否有效。