首页 > 解决方案 > asp.net OwinContext 身份验证

问题描述

OwinContext有一个IAuthenticationManager类型的属性调用Authentication,怎么能用我实现的类而不是默认实现来设置这个属性。我进行了搜索和搜索,但没有找到任何可以帮助我的信息....谢谢。

标签: asp.net-mvcauthenticationowin

解决方案


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

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


推荐阅读