Merge pull request #6114 from umbraco/v7/bug/2178-disable-mini-profiler

Disable Mini Profiler
This commit is contained in:
Shannon Deminick
2019-08-16 15:37:05 +10:00
committed by GitHub
@@ -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
{
@@ -24,6 +27,20 @@ namespace Umbraco.Web.Profiling
{
// 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>
@@ -118,4 +135,4 @@ namespace Umbraco.Web.Profiling
}
}
}
}
}