c# - Azure AD 错误请求

标签 c# azure single-sign-on azure-active-directory azure-authentication

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

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

第二种情况是我总是收到“错误请求 - 请求太长错误”。 我错过了什么配置?

这是我使用的代码:

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 注册表项的设置,以便用户的请求 header 不会超过这些值。

请参见此处: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

关于c# - Azure AD 错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50616267/

相关文章:

c# - sqlite-net 异步 API 是否支持处置?

c# - WP 8.1 XAML 应用程序在 MapControl 的 Windows 10 Mobile 上时常崩溃

azure - 在azure逻辑应用程序中如何从json字符串中提取图像并将其保存在sharepoint中

python - 在 Python 中实现 SAML 客户端

java - Cas - 自定义可接受的使用策略 View

single-sign-on - 同一域中的 OpenID Connect RP 和 OP?

c# - 我怎样才能在 C# 的异常中获取错误号而不是错误消息?

c# - 将选项卡控件的 SelectedItem 与 MVVM 绑定(bind)是个好主意吗?

database - Microsoft Azure 开发入门

azure - az acr 登录时出现主题名称和颁发者身份验证错误