【问题标题】:Azure AD Bad RequestAzure AD 错误请求
【发布时间】: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


【解决方案1】:

您是否使用一组特定的凭据登录?如果用户属于太多 Azure AD 组,则可能会发生此问题。您可以删除您所属的用户组的数量,也可以增加服务器上 MaxFieldLength 和 MaxRequestBytes 注册表项的设置,以使用户的请求标头不超过这些值。

请看这里:https://support.microsoft.com/en-us/help/2020943/http-400-bad-request-request-header-too-long-response-to-http-request

另见:https://medium.com/@marilee.turscak/reply-urls-vs-postlogoutredirecturis-in-azure-active-directory-aad-20f57a03267b

【讨论】:

    猜你喜欢
    • 2016-12-03
    • 2017-03-19
    • 2020-08-28
    • 1970-01-01
    • 2022-01-05
    • 2018-05-02
    • 2018-10-06
    • 2020-07-05
    • 1970-01-01
    相关资源
    最近更新 更多