Ste*_*eve 6 c# asp.net httpcontext owin asp.net-core-mvc
我在我的Asp.Net5 MVC 6 Web应用程序中使用Membership Reboot来管理我的身份,登录等.
我正在尝试让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();
Run Code Online (Sandbox Code Playgroud)
在MVC5中,这可以HttpContext.Current.GetOwinContext()像程序集中的扩展方法一样好Microsoft.Owin.Host.SystemWeb.但是,此程序集不再用于MVC6,因此HttpContext.Current无法解决.
我已经看到新的访问方式HttpContext是使用新IHttpContextAccessor界面,但这并没有解决获取Owin上下文的问题.
有没有办法在MVC6中获取当前的Owin上下文,或者当前的Owin环境字典(因为这是OwinAuthenticationService该类使用的)?
OWIN 失去了在 ASP.NET Core 1.0(又名 ASP.NET 5)中的地位,
https://docs.asp.net/en/latest/fundamentals/owin.html
但您可以在上面的页面上找到所有信息。看来 OWIN 上下文已经消失了。
| 归档时间: |
|
| 查看次数: |
2570 次 |
| 最近记录: |