Update WorkContextAccessor.cs

This commit is contained in:
jtkech
2015-10-01 21:09:44 +02:00
parent 508d97ed7d
commit f3902feb35

View File

@@ -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() {