From 6da82d93b9e2148b1d87a3c5ab70df3c12abf38d Mon Sep 17 00:00:00 2001 From: sauerc Date: Wed, 11 Jul 2012 15:13:39 -0400 Subject: [PATCH] Check HttpContext.Server.Current not null. Possibly using MiniProfiler in framework/shared code that can be used outside of IIS. --- StackExchange.Profiling/MiniProfiler.Settings.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/StackExchange.Profiling/MiniProfiler.Settings.cs b/StackExchange.Profiling/MiniProfiler.Settings.cs index 9041e25..753825d 100644 --- a/StackExchange.Profiling/MiniProfiler.Settings.cs +++ b/StackExchange.Profiling/MiniProfiler.Settings.cs @@ -49,7 +49,9 @@ where p.IsDefined(t, inherit: false) List files = new List(); files.Add(location); - string customUITemplatesPath = HttpContext.Current.Server.MapPath(MiniProfiler.Settings.CustomUITemplates); + string customUITemplatesPath = ""; + if (HttpContext.Current != null) + customUITemplatesPath = HttpContext.Current.Server.MapPath(MiniProfiler.Settings.CustomUITemplates); if (System.IO.Directory.Exists(customUITemplatesPath)) {