首页 > 解决方案 > 注销和登录后请求未通过身份验证

问题描述

我在验证请求时遇到问题。它第一次工作正常,但在用户注销并重新登录后它不再工作。顺便说一下,这是我的代码。

家庭控制器

Public ActionResult Index()
{
  if(!Request.IsAuthenticated)
  {
     return View()// Goes to the login page
  }
  else
  {
     // redirect to home page with user info
  }
}

Public void SignIn()
{
  HttpContext.GetOwinContext().Authentication.Challenge(
  new AuthenticationProperties { RedirectUri = "/Home" },
  OpenIdConnectAuthenticationDefaults.AuthenticationType);
  //After sign in this goes back to index. When first time logging in this actually works and request is authenticated. But after sign-out and sign in again, request is not authenticated anymore.
}

public void Logout()
{

  HttpContext.GetOwinContext().Authentication.SignOut(
  OpenIdConnectAuthenticationDefaults.AuthenticationType,
  CookieAuthenticationDefaults.AuthenticationType);
}

/*我是 Azure 和 SSO 的新手,我只是按照此链接中的代码https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-asp-webapp*/

标签: asp.netazuresingle-sign-onowin

解决方案


推荐阅读