diff --git a/src/Elmah.Contrib.WebApi/ElmahExceptionLogger.cs b/src/Elmah.Contrib.WebApi/ElmahExceptionLogger.cs index e3649bd..643ffa6 100644 --- a/src/Elmah.Contrib.WebApi/ElmahExceptionLogger.cs +++ b/src/Elmah.Contrib.WebApi/ElmahExceptionLogger.cs @@ -31,14 +31,14 @@ private static HttpContext GetHttpContext(HttpRequestMessage request) return null; object value; - if (!request.Properties.TryGetValue("MS_HttpContext", out value)) - return null; - - HttpContextBase context = value as HttpContextBase; - if (context == null) - return null; - - return context.ApplicationInstance.Context; + if (request.Properties.TryGetValue("MS_HttpContext", out value)) + { + HttpContextBase context = value as HttpContextBase; + if (context != null) + return context.ApplicationInstance.Context; + } + + return HttpContext.Current; } } }