I am using the MiniProfiler for a small ASP.Net web application. It is great when in development, but I would like a simple way to enable/disable it in production mode.
After reading How to hide miniprofiler and the tutorial, I came up with a method where I use a boolean in Global.asax
:
bool useProfiler = false;
...
protected void Application_BeginRequest()
{
MiniProfiler profiler = null;
if (useProfiler)
{
profiler = MiniProfiler.Start();
}
}
protected void Application_EndRequest()
{
if (useProfiler)
{
MiniProfiler.Stop();
}
}
But the problem is the MiniProfiler always starts, no matter what the value of useProfiler
is.
Do I need to have some tests when calling @MiniProfiler.RenderIncludes()
as well?