I use Membership Reboot in my Asp.Net5 MVC 6 web application to manage my identity, logins, etc.
I am trying to get an MR OwinAuthenticationService , working as an implementation for the IAuthenticationService interface that I enter in my controllers.
The sample for this includes an IAuthenticationService injection, depending on the following Autofac registration:
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();
In MVC5, this would be great if HttpContext.Current.GetOwinContext() as an extension method in the Microsoft.Owin.Host.SystemWeb assembly. However, this assembly is no longer used in MVC6, so HttpContext.Current not allowed.
I saw that the new way to access HttpContext uses the new IHttpContextAccessor interface, but this does not solve the problem of getting Owin context.
Is there a way to get the current Owin context in MVC6 or the current Owin environment dictionary (from what uses the OwinAuthenticationService class)?
source share