【发布时间】:2023-04-08 02:58:01
【问题描述】:
我使用https://myapps.microsoft.com/ 作为我的登录页面。
但是,在某些情况下,当我从仪表板单击我的应用程序时, 当页面被重定向时,我的会话已过期。我必须关闭并再次单击它,这是我在页面中获取会话的时间。
第二种情况是我总是收到“错误请求 - 请求太长错误”。 我错过了什么配置?
这是我使用的代码:
public class Logon
{
[Authorize]
public void Authenticate()
{
if (ClaimsPrincipal.Current.Identity.IsAuthenticated)
{
string userfirstname = ClaimsPrincipal.Current.FindFirst(ClaimTypes.GivenName).Value;
string userlastname = ClaimsPrincipal.Current.FindFirst(ClaimTypes.Surname).Value;
// do some checking
// set session and redirect
// when page is redirected to Home Index, session checking occur
Response.Redirect("~/Home/Index");
}
}
}
至于 Azure 设置
我的主页 URL 和回复 URL 设置为:https://mysite/logon/authenticate 托管在我的本地 IIS 上。
我通过 Azure AD 面板中的应用注册菜单添加了我的应用。
谢谢。
【问题讨论】:
-
请求太长通常发生在您进入应用程序和 Azure AD 的重定向循环时。饼干充满了随机数。尝试将回复 URL 设置为具有
[AllowAnonymous]并重定向到您希望他们去的地方的操作。这在几年前为我解决了经典 MVC 中的问题。
标签: c# azure single-sign-on azure-active-directory azure-authentication