我使用Membership Reboot我Asp.Net5 MVC 6 Web應用程序來管理我的身份,登錄等GetOwinContext在MVC 6
我試圖讓MR的OwinAuthenticationService工作作爲IAuthenticationService
接口的實現,我是依賴注入我的控制器。
的樣品,這涉及注入IAuthenticationService
使用以下Autofac登記取決於:
builder.Register(ctx=>HttpContext.Current.GetOwinContext()).As<IOwinContext>();
builder.Register<IAuthenticationService>(ctx =>
{
var owin = ctx.Resolve<IOwinContext>();
return new OwinAuthenticationService(
MembershipRebootOwinConstants.AuthenticationType,
ctx.Resolve<IUserAccountService>(),
owin.Environment);
}).InstancePerLifetimeScope();
在MVC5,這將是作爲細如HttpContext.Current.GetOwinContext()
在Microsoft.Owin.Host.SystemWeb
組件的擴展方法。但是,此組件不再用於MVC6,因此HttpContext.Current
無法解析。
我已經看到,訪問HttpContext
的新方法是使用新的IHttpContextAccessor
接口,但這並不能解決獲取Owin上下文的問題。
有沒有辦法在MVC6或當前的Owin環境字典中獲得當前的Owin上下文(因爲這就是OwinAuthenticationService
類使用的)?
我正在處理一些與Owin一起使用的身份驗證,但在新的ASP.NET Core世界中還不支持,並且遇到了同樣的問題。你有沒有找到任何方式讓舊的工作與新的?我無法讓我的註銷觸發在啓動時從控制器中的Owin上下文中配置的內容,而無需訪問Owin上下文。 –
我有同樣的問題。我需要一個Owin上下文來實際SignOut用戶。任何解決方法_ –