47

Recently we upgraded to MiniProfiler version 2.0.1 from v1.7, and since then we have not been able to use it in our MVC3 website because when it tries to get its resources, it instead gets a 404.

An example resource call is: /mini-profiler-resources/includes.js?v=tNlJPuyuHLy/d5LQjyDuRbWKa0weCpmO3xkO6MH4TtA=

In searching around, most people are suggesting that simply setting runAllManagedModulesForAllRequests should be set to true. For giggles, I went ahead and set it to true, and yes it did work. But that is not an acceptable answer.

How can I keep runAllManagedModulesForAllRequests=false and still use MiniProfiler v2?

Adam Spicer
  • 2,703
  • 25
  • 37
  • 1
    well ... we need to figure out what broke first, does trunk exhibit the same issue? I know that there were requests to serve stuff extensionless in the past to work around this – Sam Saffron Apr 25 '12 at 10:32
  • It seems this post is talking about the same issue: http://stackoverflow.com/q/10212725/498969 The code I pulled down was from your nuget package, so I can't confirm the issue from the trunk at the moment. Version 2 no longer requires that I register those three handlers (miniProfilerJS, miniProfilerCSS, miniProfilerTmpl) right? Are you getting around that by registering routes from the MiniProfilerHandler? – Adam Spicer Apr 25 '12 at 11:07
  • Im thinking the cleanest design we can move to is a single endpoint to serve all the stuff eg: /mini-profiler-handler?jquery.js&kfslsfjklskd etc ... can you post on http://community.miniprofiler.com – Sam Saffron Apr 28 '12 at 00:14
  • @SamSaffron, It looks like David's answer below works! I added the info to your KB in [community tracker](http://community.miniprofiler.com/permalinks/13/how-to-use-miniprofiler-with-runallmanagedmodulesforallrequests-set-to-false). – Adam Spicer Apr 29 '12 at 01:48
  • 1
    Thanks @Adam ... published it – Sam Saffron Apr 29 '12 at 03:45

3 Answers3

74

I had the same issue - the resources being requested use "static" file extensions (such as .js) and therefore IIS wants to handle them using its static file handler.

Luckily all of the MiniProfiler resources are requested with the path mini-profiler-resources, so you can add the following to your web.config:

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

The entry above instructs IIS that any request for the mini-profiler-resources path to be routed through ASP.NET.

Jesse
  • 8,605
  • 7
  • 47
  • 57
David Duffett
  • 3,145
  • 2
  • 26
  • 27
  • 1
    What would we have to do to support IIS 7 running in classic mode? – goalie7960 May 16 '12 at 16:17
  • 3
    Hmm.. if you're running in classic mode then you could probably add a similar entry into . I believe the format is the same exception maybe leave off the resourceType and preCondition attributes. – David Duffett May 18 '12 at 09:44
  • 5
    This works great, I believe this breaking change should be documented and highlighted in the http://miniprofiler.com/ site. – Jalal El-Shaer Jun 23 '12 at 21:37
  • 4
    A breaking change in .NET 4.5 currently requires us to add the handler registration @David mentions as a workaround. Setting `runAllManagedModulesForAllRequests=true` doesn't fix the problem. – Loren Paulsen Jun 30 '12 at 08:31
  • 4
    Please help me, I also use Classic mode and MVC 4, I tried to add to httpHandlers, but it doesn't implement type="System.Web.Routing.UrlRoutingModule". Could you show me shift httpHalder you use? – Sergey Jan 23 '13 at 15:48
0

As David Duffet says in the comments in the accepted answer, you might also need to add the following entry to your web config. This worked for me:

<system.web>
    <httpHandlers>
      <add verb="*" type="System.Web.Routing.UrlRoutingModule" path="mini-profiler-resources/*"/>
    </httpHandlers>
</system.web>
DLeh
  • 23,806
  • 16
  • 84
  • 128
0

I had a similar issue and what I did to fix it was change the application pool to 'integrated' and then I added this new line below to my web.config and it then worked.

Here is what the complete web.config looks like now for 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>
Jeff
  • 134
  • 1
  • 5