将runAllManagedModulesForAllRequests设置为false运行MiniProfiler

最近,我们从V1.7升级到了MiniProfiler 2.0.1版本,从那以后,我们一直无法在我们的MVC3网站上使用它,因为当它试图获得它的资源时,它会得到一个404。

资源调用示例如下: /mini-profiler-resources/includes.js?v=tNlJPuyuHLy/d5LQjyDuRbWKa0weCpmO3xkO6MH4TtA=

在四处search时,大多数人都build议只需将runAllManagedModulesForAllRequests设置为true 。 为了笑声,我继续前进,并将其设定为真,而且确实有效。 但这不是一个可以接受的答案。

我怎么能保持runAllManagedModulesForAllRequests=false ,仍然使用runAllManagedModulesForAllRequests=false V2?

我有同样的问题 – 被请求的资源使用“静​​态”文件扩展名(如.js ),因此IIS想要使用其静态文件处理程序来处理它们。

幸运的是,所有的MiniProfiler资源都通过mini-profiler-resources的path请求,所以你可以在你的web.configjoin以下内容:

 <system.webServer> ... <handlers> <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" /> </handlers> </system.webServer> 

上面的条目指示IIS通过ASP.NET路由到mini-profiler-resourcespath的任何请求。

正如David Duffet在接受的答案中的评论中所说,您可能还需要将以下条目添加到您的Webconfiguration中。 这对我工作:

 <system.web> <httpHandlers> <add verb="*" type="System.Web.Routing.UrlRoutingModule" path="mini-profiler-resources/*"/> </httpHandlers> </system.web> 

我有一个类似的问题,我所做的修复它是将应用程序池更改为“集成”,然后我将下面的这一行添加到我的web.config然后它工作。

这里是完整的web.config现在为mini-profiler的样子。

 <system.webServer> <modules runAllManagedModulesForAllRequests="false" /> <validation validateIntegratedModeConfiguration="false"/> <!-- Here is the new line --> <handlers> <add name="MiniProfiler" verb="*" type="System.Web.Routing.UrlRoutingModule" path="mini-profiler-resources/*"/> </handlers> </system.webServer>