mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#5306: Injecting HttpContextBase directly.
This will ensure that an actual HttpContext object will be available in case of background task operations thanks to the way HttpContextBase is registered (providing a placeholder object in case of background operations).
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Layouts.Filters;
|
||||
using Orchard.Mvc;
|
||||
|
||||
namespace Orchard.Layouts.Services {
|
||||
public class CurrentControllerAccessor : ICurrentControllerAccessor {
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
public CurrentControllerAccessor(IHttpContextAccessor httpContextAccessor) {
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
private readonly IWorkContextAccessor _wca;
|
||||
private readonly HttpContextBase _httpContext;
|
||||
|
||||
public CurrentControllerAccessor(IWorkContextAccessor wca, HttpContextBase httpContext) {
|
||||
_wca = wca;
|
||||
_httpContext = httpContext;
|
||||
}
|
||||
|
||||
public Controller CurrentController {
|
||||
get { return (Controller) _httpContextAccessor.Current().Items[ControllerAccessorFilter.CurrentControllerKey]; }
|
||||
get { return (Controller) _httpContext.Items[ControllerAccessorFilter.CurrentControllerKey]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user