سؤال

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?

هل كانت مفيدة؟

المحلول

The problem came from the fact that the MiniProfiler.MVC package has an example project included. A MiniProfiler.cs file is created in the App_Start folder, and starts with the web application.

Just removing this file solved the problem.

You can also delete Views/Shared/_MINIPROFILER UPDATED Layout.cshtml which is part of the example project.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top