From afca2e70bd44ae0c6a812fdfdd7ff0df4d68822c Mon Sep 17 00:00:00 2001 From: elitsa Date: Tue, 13 Aug 2019 14:17:14 +0200 Subject: [PATCH 1/2] Removing the MiniProfiler routes if solution is not in debug mode. --- .../Profiling/WebProfilerProvider.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Profiling/WebProfilerProvider.cs b/src/Umbraco.Web/Profiling/WebProfilerProvider.cs index ffd1871ecc..68e1555884 100644 --- a/src/Umbraco.Web/Profiling/WebProfilerProvider.cs +++ b/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 { @@ -24,6 +27,19 @@ namespace Umbraco.Web.Profiling { // booting... _bootPhase = BootPhase.Boot; + + // Remove Mini Profiler routes when not in debug mode + if (GlobalSettings.DebugMode == false) + { + var prefix = 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); + } + } } /// @@ -118,4 +134,4 @@ namespace Umbraco.Web.Profiling } } } -} \ No newline at end of file +} From cd355910b390b1200e2037154ea19525476519a5 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 16 Aug 2019 15:34:49 +1000 Subject: [PATCH 2/2] strangely i need the fully qualified name here else i get an error, otherwise works great. --- src/Umbraco.Web/Profiling/WebProfilerProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Profiling/WebProfilerProvider.cs b/src/Umbraco.Web/Profiling/WebProfilerProvider.cs index 68e1555884..e0dcfcf9b1 100644 --- a/src/Umbraco.Web/Profiling/WebProfilerProvider.cs +++ b/src/Umbraco.Web/Profiling/WebProfilerProvider.cs @@ -31,7 +31,8 @@ namespace Umbraco.Web.Profiling // Remove Mini Profiler routes when not in debug mode if (GlobalSettings.DebugMode == false) { - var prefix = MiniProfiler.Settings.RouteBasePath.Replace("~/", string.Empty); + //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()) {