Making MiniProfiler work in the Orchard dashboard
MiniProfiler is a wonderful module. It’s especially good at showing you the select n+1 problems in your Orchard applications. For some reason that is not entirely clear to me, however, it is only active on the front-end. If you have to debug a performance issue in the dashboard, you’re out of luck. Fortunately, the limitation is entirely arbitrary, easy to find, and easy to remove.
If you go to the Four2n.MiniProfiler module, inside of the Filters folder, you’ll find a file called ProfilerFilter.cs. The class in this file is what will inject the MiniProfiler UI into the page. In the IsActivable method, you’ll find the following lines of code:
if (AdminFilter.IsApplied(new RequestContext(this.workContext.HttpContext, new RouteData())))
{
return false;
}
Comment them out, and… TADA! MiniProfiler is now active in the dashboard.
By the way, one thing to remember, when you’re profiling your application, is to disable all caching, especially SysCache. If you don’t, many problems will hide and it’s likely that you will only find them later, in production, when it’s too late.