How to use MiniProfiler with runAllManagedModulesForAllRequests set to false?

We are using MiniProfiler in ASP.NET 4 hosted in IIS 7.5. Our web.config is configured with runAllManagedModulesForAllRequests=false as we don’t want ASP.NET to process every static file.

We started having trouble running MiniProfiler after upgrading to version 2. So I posted a question on Stack Overflow.

The answer was simple, you need to register the path MiniProfiler uses as a handler for the UrlRoutingModule.

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