asp.net-mvc - 写入 Session 会中断 ASP.NET MVC OpenId 登录
问题描述
试图理解为什么在使用带有 OpenID Connect 的 ASP.NET Web 应用程序时写入 Session 会中断登录过程。
让我们考虑一个微软设计的例子https://github.com/AzureADQuickStarts/AppModelv2-WebApp-OpenIDConnect-DotNet
public ActionResult Index()
{
return View();
}
/// Send an OpenID Connect sign-in request.
public void SignIn()
{
if (!Request.IsAuthenticated)
{
HttpContext.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
}
/// Send an OpenID Connect sign-out request.
public void SignOut()
{
HttpContext.GetOwinContext().Authentication.SignOut(
OpenIdConnectAuthenticationDefaults.AuthenticationType,
CookieAuthenticationDefaults.AuthenticationType);
}
它工作正常,直到我在 Session 中写了一些东西:
public ActionResult Index()
{
Session["TEST"] = "TEST"; // Let's make a SignIn disruption
return View();
}
一旦我这样做,登录就会停止工作;它会将您重定向到 Microsoft AD,后者将返回未经身份验证的索引。此外,在重新启动应用程序之前,在调试期间删除此代码将不起作用。有时它允许您进行一轮 SingIn/SingOut,但所有连续的 SignIn 都失败。
任何人都知道为什么会发生这种情况以及从哪里开始寻找解决方案?
解决方案
推荐阅读
- go - 当我在地址中使用端口时,Kubernetes 日志不打印请求输出
- authentication - .NET Core MVC 中多种身份验证类型(包括 Azure AD)的单一登录页面
- wix - 替换默认 WelcomeDlg 对话框的问题
- node.js - socket.io 不会关闭之前的连接
- tekton - 将 ENV 变量从一个 Tekton Task 步骤传递到下一个?
- c# - Net Core 3.0 和 Serilog 产生像 Microsoft.Extensions.Logging 这样的输出
- ruby - 涌入将少量标签值写入标签键以获取点
- php - Laravel - 如何采摘嵌套集合?
- android - 如何在运行时永久移动整个 ConstraintLayout?
- python - 为什么 numpy.argsort() 对关系的索引进行洗牌?