Skip to content

Commit

Permalink
Merge pull request #6114 from umbraco/v7/bug/2178-disable-mini-profiler
Browse files Browse the repository at this point in the history
Disable Mini Profiler
  • Loading branch information
Shazwazza committed Aug 16, 2019
2 parents 249126a + cd35591 commit cb7440b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Umbraco.Web/Profiling/WebProfilerProvider.cs
@@ -1,7 +1,10 @@
using System;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Routing;
using StackExchange.Profiling;
using Umbraco.Core.Configuration;

namespace Umbraco.Web.Profiling
{
Expand All @@ -24,6 +27,20 @@ public WebProfilerProvider()
{
// booting...
_bootPhase = BootPhase.Boot;

// Remove Mini Profiler routes when not in debug mode
if (GlobalSettings.DebugMode == false)
{
//NOTE: Keep the global fully qualified name, for some reason without it I was getting null refs
var prefix = global::StackExchange.Profiling.MiniProfiler.Settings.RouteBasePath.Replace("~/", string.Empty);

using (RouteTable.Routes.GetWriteLock())
{
var routes = RouteTable.Routes.Where(x => x is Route r && r.Url.StartsWith(prefix)).ToList();
foreach(var r in routes)
RouteTable.Routes.Remove(r);
}
}
}

/// <summary>
Expand Down Expand Up @@ -118,4 +135,4 @@ public override MiniProfiler GetCurrentProfiler()
}
}
}
}
}

0 comments on commit cb7440b

Please sign in to comment.