From e9799d553725fd4a426e5be3933deb1cea48be31 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 1 Sep 2015 15:05:28 +0100 Subject: [PATCH] Fixed a potential "ValueFactory attempted to access the Value property of this instance" issue. The underlying cause of such an error is a recursive call issue, where some code in a background task accesses the current http context (which is a stand in), while its construction also (indirectly) accesses the http context in order to get the site content item and query the configured BaseUrl. In theory we could access this information straight from the database without loading the Site content item, but since the URL value doesn't really matter it is better to keep it simple. --- src/Orchard/Mvc/HttpContextAccessor.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Orchard/Mvc/HttpContextAccessor.cs b/src/Orchard/Mvc/HttpContextAccessor.cs index 8fe8e4f0a..91c7c3b0d 100644 --- a/src/Orchard/Mvc/HttpContextAccessor.cs +++ b/src/Orchard/Mvc/HttpContextAccessor.cs @@ -3,7 +3,6 @@ using System.Collections.Concurrent; using System.Web; using Autofac; using Orchard.Mvc.Extensions; -using Orchard.Settings; namespace Orchard.Mvc { public class HttpContextAccessor : IHttpContextAccessor { @@ -20,10 +19,11 @@ namespace Orchard.Mvc { } public HttpContextBase CreateContext(ILifetimeScope lifetimeScope) { - return new MvcModule.HttpContextPlaceholder(_threadStaticContexts, _contextKey, () => { - var baseUrl = lifetimeScope.Resolve().GetSiteSettings().BaseUrl; - return !String.IsNullOrEmpty(baseUrl) ? baseUrl : "http://localhost"; // Return a valid URL always. - }); + return new MvcModule.HttpContextPlaceholder( + _threadStaticContexts, + _contextKey, + () => "http://localhost" // Use a valid URL always for the fake request. The value itself doesn't matter. + ); } private HttpContextBase GetContext() {