Search code examples
c#asp.net-mvcmvc-mini-profiler

Is it possible to disable mini profiler handler?


I want to disable profiling and also mini-profiler-resources/results, mini-profiler-resources/results-list endpoints depending on some boolean flag. I know that i can skip starting profiler for the request but still endpoints to results are available (exception is thrown but they exist).


Solution

  • Ok so I analyzed code and I can answer to my own question. Mini profiler is registered as IRouteHandler and IHttpHandler. If you'll use any method from mini profiler it will initialize this module by firing ctor of WebRequestProfilerProvider. So if you want to disable mini profiler and all routes (mini-profiler-resources/results, mini-profiler-resources/results-index) make sure that you don't fire any mini profile method including:

    • ProfilingViewEngine registration.
    • ProfilingActionFilter (Custom profiler filter for MVC).
    • Include method in view for scripts and styles.
    • MiniProfiler.Start and .Stop methods.