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