asp.net - 注销和登录后请求未通过身份验证
问题描述
我在验证请求时遇到问题。它第一次工作正常,但在用户注销并重新登录后它不再工作。顺便说一下,这是我的代码。
家庭控制器
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*/
解决方案
推荐阅读
- reactjs - 在 Gatsby 站点中维护/访问全局状态
- sql - 基于条件的 SQL 选择
- python - 无法安装噪声模块
- mysql - MySQL:BTREE 慢速索引路径(表大小:723704015 行)
- python - 创建一个函数,该函数接收名称为数组的字符串,然后打印每个元素 [python]
- node.js - TypeError:Router.use() 需要一个中间件函数,但有一个未定义的
- c# - 使用 iTextSharp 将图像插入 PDF 表单
- linux - bash 中过度设计的 checkroot
- java - swapWords 方法不返回修改后的 ArrayList
在爪哇 - android - 颤振:图像 BoxFit.cover 在堆栈中不起作用