Azure AD 错误请求

Azure AD Bad Request

我正在使用 https://myapps.microsoft.com/ 作为我的登录页面。

但是有些情况下,当我从仪表板中单击我的应用程序时, 重定向页面时,会话已过期。我必须关闭并再次单击它,这是我在页面中获得会话的时间。

第二种情况是我总是得到 "Bad Request - Request Too Long error "。 我错过了什么配置?

这是我使用的代码:

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 组,则可能会发生此问题。您可以删除您所属的用户组的数量,或者增加服务器上 MaxFieldLength 和 MaxRequestBytes 注册表项的设置,以便用户的请求headers 不超过这些值。

看这里: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