asp.net-mvc - asp.net OwinContext 身份验证
问题描述
OwinContext有一个IAuthenticationManager类型的属性调用Authentication,怎么能用我实现的类而不是默认实现来设置这个属性。我进行了搜索和搜索,但没有找到任何可以帮助我的信息....谢谢。
解决方案
经过大量测试,我发现了问题所在。在启动 owin 身份验证时,我有以下代码 app.UseCookieAuthentication(new CookieAuthenticationOptions { ..... CookieSecure = CookieSecureOption.Always ..... }
因为所有请求都在 http 而不是 https 中,所以登录后 cookie 不会持续存在。将枚举更改为 SameAsRequest,解决了问题。
推荐阅读
- ubuntu - 如何强制 ubuntu 服务器每小时执行一次命令?
- ios - 文本字段和动画 Swift 5 的问题
- excel - 使用 PasteSpecial 时 Excel 忽略逗号
- sql-server - SQL Server:如何从 Json 对象中删除键
- python - matmul:输入操作数 1 的核心维度 0 不匹配,具有 gufunc 签名 (n?,k),(k,m?)->(n?,m?)(大小 20 与 10 不同)
- html - Vue 组件:使用
- angular - 具有删除功能的 mat-option
- ggplot2 - 如何绘制 glm 模型(伽马族)的置信区间?
- google-apps-script - 每小时多次调用 Google Apps 脚本基于时间的每小时触发器
- angular - 如何在角度组件中引用 Html Id