From f3902feb353382cc0a7db7a0d78579a239dfdf11 Mon Sep 17 00:00:00 2001 From: jtkech Date: Thu, 1 Oct 2015 21:09:44 +0200 Subject: [PATCH 1/2] Update WorkContextAccessor.cs --- src/Orchard/Environment/WorkContextAccessor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Orchard/Environment/WorkContextAccessor.cs b/src/Orchard/Environment/WorkContextAccessor.cs index af709d0d5..e572d21f6 100644 --- a/src/Orchard/Environment/WorkContextAccessor.cs +++ b/src/Orchard/Environment/WorkContextAccessor.cs @@ -27,7 +27,11 @@ namespace Orchard.Environment { } public WorkContext GetContext(HttpContextBase httpContext) { - return httpContext.Items[_workContextKey] as WorkContext; + if (!httpContext.IsBackgroundContext()) + return httpContext.Items[_workContextKey] as WorkContext; + + WorkContext workContext; + return EnsureThreadStaticContexts().TryGetValue(_workContextKey, out workContext) ? workContext : null; } public WorkContext GetContext() { From 44a342c4fed60efe4fac54b0766ac8d2f2ec9481 Mon Sep 17 00:00:00 2001 From: jtkech Date: Fri, 2 Oct 2015 02:15:08 +0200 Subject: [PATCH 2/2] Update DefaultCacheStorageProvider.cs --- .../Services/DefaultCacheStorageProvider.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Services/DefaultCacheStorageProvider.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Services/DefaultCacheStorageProvider.cs index a878a5870..12c547f84 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Services/DefaultCacheStorageProvider.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Services/DefaultCacheStorageProvider.cs @@ -27,7 +27,8 @@ namespace Orchard.OutputCache.Services { } public void Remove(string key) { - _workContext.HttpContext.Cache.Remove(key); + if (_workContext.HttpContext != null) + _workContext.HttpContext.Cache.Remove(key); } public void RemoveAll() { @@ -63,4 +64,4 @@ namespace Orchard.OutputCache.Services { .Count(x => x.Tenant.Equals(_tenantName, StringComparison.OrdinalIgnoreCase)); } } -} \ No newline at end of file +}