Asp.net mvc asp.net文本身份验证

Asp.net mvc asp.net文本身份验证,asp.net-mvc,authentication,owin,Asp.net Mvc,Authentication,Owin,OwinContext具有IAAuthenticationManager类型的属性调用身份验证,如何使用我实现的类而不是默认实现来设置此属性。 我搜索了又搜索,但没有找到任何可以帮助我的信息。。。。 谢谢。希望这就是您正在寻找的使用OwinContext的自定义身份验证 只是一个想法,而不是一个确认的想法-Ypu可以在Startup.Auth.cs中编辑Owin管道配置: public void Configure(IAppBuilder app) { _container = n

OwinContext具有IAAuthenticationManager类型的属性调用身份验证,如何使用我实现的类而不是默认实现来设置此属性。 我搜索了又搜索,但没有找到任何可以帮助我的信息。。。。
谢谢。

希望这就是您正在寻找的使用OwinContext的自定义身份验证

只是一个想法,而不是一个确认的想法-Ypu可以在Startup.Auth.cs中编辑Owin管道配置:

public void Configure(IAppBuilder app)
 {
     _container = new Container();
     _container.Register<IAuthenticationManager>(customAuthMgrInstance ); 
 }
public void配置(IAppBuilder应用程序)
{
_容器=新容器();
_container.Register(customAuthMgrInstance);
}

我假设它将替换OwinContext的AuthenticationManager依赖项。如果可以的话,请告诉我。我自己无法尝试,因为我手头没有足够的资源

经过大量测试,我发现了问题所在。在启动owin身份验证时,我有以下代码 app.UseCookieAuthentication(新的CookieAuthenticationOptions{ ..... CookieSecure=CookieSecureOption.始终 ..... }

因为所有请求都是http而不是https,所以cookie在登录后不会持久化。
将枚举更改为SameAsRequest解决了问题。

我已经这样做了,我想做的是在OwinContext类上用我的实现替换身份验证属性是的。Owin使用默认的unity容器进行依赖项注入,同样的方法。你是说asp.net核心还是asp.net?我的站点在asp.net中是的,它应该可以在bo上工作但是,如果您没有使用DI容器-请遵循此方法-此方法不会替换OwinContext对象的authenticationmanager对象,尽管我可以登录,但OwinContext.Request.User和OwinContext.Authentication.User都为空,因此如果用户经过身份验证,我将无效