From c9887f4d39ceea779bbc210c542982a36271f32b Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 28 May 2015 00:59:48 +0200 Subject: [PATCH] Cherry picked 1e83068b8c12878431b5503bbe4c32d619d7811d. --- src/Orchard/Mvc/HttpContextAccessor.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Orchard/Mvc/HttpContextAccessor.cs b/src/Orchard/Mvc/HttpContextAccessor.cs index b13d6fe25..8fa47afbc 100644 --- a/src/Orchard/Mvc/HttpContextAccessor.cs +++ b/src/Orchard/Mvc/HttpContextAccessor.cs @@ -22,18 +22,12 @@ namespace Orchard.Mvc { var httpContext = HttpContext.Current; if (httpContext == null) { return null; - } + } - try { - // The "Request" property throws at application startup on IIS integrated pipeline mode. - if (httpContext.Request == null) { - return null; - } - } - catch (Exception) { - return null; - } - return httpContext; + public HttpContextBase Current() { + // TODO: HttpContextBase is not registred in the "shell" lifetime scope, so resolving it will cause an exception. + + return HttpContext.Current != null ? new HttpContextWrapper(HttpContext.Current) : null; } } } \ No newline at end of file