VirtualPathProvider doesn't (quite) work in production on IIS 7.5

限于喜欢 提交于 2019-12-04 15:31:38

IIS 7.5 will handle the static files itself. You need to put a line for each static file you want it to ignore in your web.config file to make them get routed through your VPP. See below for examples.

<system.webServer>
    <handlers>
        <add name="Images" path="*.png" verb="GET,HEAD,POST" type="System.Web.StaticFileHandler" modules="ManagedPipelineHandler" resourceType="Unspecified" />
        <add name="Stylesheets" path="*.css" verb="GET,HEAD,POST" type="System.Web.StaticFileHandler" modules="ManagedPipelineHandler" resourceType="Unspecified" />
     </handlers>
 </system.webServer>

Maybe the problem is that requests for static files are not going through ASP.NET by default in IIS.

Try whether turning on runAllManagedModulesForAllRequests in web.config helps. e.g.

<modules runAllManagedModulesForAllRequests="true" />

Take a look at this post. It explains how to get static files through a virtual path provider in IIS 7. I believe this will solve your problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!