From 34d6e5198ad2503e51cd62db796bcd7039c2e6ef Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Thu, 26 Dec 2013 19:28:55 -0500 Subject: [PATCH] #20385 Fixing Logging Bugs Work Item: 20385 --- src/Orchard/Environment/RunningShellTable.cs | 10 +++++++++- src/Orchard/Logging/OrchardLog4netLogger.cs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Orchard/Environment/RunningShellTable.cs b/src/Orchard/Environment/RunningShellTable.cs index 3d6a6cc1e..a23338504 100644 --- a/src/Orchard/Environment/RunningShellTable.cs +++ b/src/Orchard/Environment/RunningShellTable.cs @@ -107,7 +107,15 @@ namespace Orchard.Environment { public ShellSettings Match(HttpContextBase httpContext) { // use Host header to prevent proxy alteration of the orignal request - return Match(httpContext.Request.Headers["Host"] ?? string.Empty, httpContext.Request.AppRelativeCurrentExecutionFilePath); + var httpRequest = httpContext.Request; + if(httpRequest == null) { + return null; + } + + var host = httpRequest.Headers["Host"]; + var appRelativeCurrentExecutionFilePath = httpRequest.AppRelativeCurrentExecutionFilePath; + + return Match(host ?? string.Empty, appRelativeCurrentExecutionFilePath); } public ShellSettings Match(string host, string appRelativePath) { diff --git a/src/Orchard/Logging/OrchardLog4netLogger.cs b/src/Orchard/Logging/OrchardLog4netLogger.cs index ebf9a1eca..083d94f23 100644 --- a/src/Orchard/Logging/OrchardLog4netLogger.cs +++ b/src/Orchard/Logging/OrchardLog4netLogger.cs @@ -68,7 +68,7 @@ namespace Orchard.Logging { } var ctx = HttpContext.Current; - if (ctx != null) { + if (ctx != null && ctx.Request != null) { ThreadContext.Properties["Url"] = ctx.Request.Url.ToString(); } }