ASP.NET MVC错误403禁止Microsoft-azure-Application-gateway/v2

发布于 2025-02-10 08:03:30 字数 1464 浏览 1 评论 0原文

我关注此tutorial 从Microsoft添加Microsoft登录到我的项目 - .NET 4.7.2上的ASP.NET MVC。

我将登录到我的Microsoft帐户访问主页。但是,当我尝试再次注销并重新登录时,它不是到达主页,而是抛出403禁止Microsoft-Asplication-application-gateway/v2。我试图删除历史记录并关闭页面并能够登录,但是当我尝试第二次尝试时,我会再次遇到相同的错误。

我检查了cookie历史记录,似乎cookie .aspnet.cookies正在引起问题。当我尝试删除.aspnet.cookies时,我可以访问该页面而不会出现任何错误。

我尝试实现samesitecookiemanager从此教程,并添加到我的startup.cs中,希望它会有所帮助,但我对此没有任何运气。

public void Configuration(IAppBuilder app)
{
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
        LoginPath = new PathString("/Home/Login"),
        CookieSameSite = SameSiteMode.Lax,
        CookieManager = new SameSiteCookieManager(new SystemWebCookieManager())
    });
}   

谁能指出这里的问题?我一直在为此挣扎了近2周。真的很感谢这里的任何帮助。

I follow this tutorial from Microsoft to add Microsoft sign in into my project - ASP.NET MVC on .NET 4.7.2.

I managed login into my Microsoft account access the main page. However, when I tried to logout and re-login again, instead of reaching the main page, it throws 403 forbidden Microsoft-Azure-Application-Gateway/v2. I tried to delete the history and close the page, and able to login, but when I tried the 2nd attempt I will get the same error again.

I checked the cookies history and seems like this cookie .AspNet.Cookies is causing the problem. When I tried to remove .AspNet.Cookies, I'm able to access the page without any error.

enter image description here

I tried to implement SameSiteCookieManager class from this tutorial and added into my startup.cs with hopes that it will help, but I have no luck with that.

public void Configuration(IAppBuilder app)
{
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
        LoginPath = new PathString("/Home/Login"),
        CookieSameSite = SameSiteMode.Lax,
        CookieManager = new SameSiteCookieManager(new SystemWebCookieManager())
    });
}   

Can anyone pointed out what is the issue here? I have been struggling with this for almost 2 weeks. Really appreciate any kind of help here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪心 2025-02-17 08:03:30

ASP.NET MVC错误403禁止Microsoft-azure-Application-gateway/v2

  • 我遵循了给定的文档,并且能够再次登录,注销和重新登录而没有任何问题, 通过更改Azure Active Directory
  • 导航到 Azure Portal => Azure Active导演 y =>您的 注册应用 => 身份验证 => 添加平台
  • 单击 添加paltform =>选择 Web =>添加 重定向uris
  • 隐性授予和混合流量< /strong> ,确保选择 id令牌 复选框被选择=&gt; 配置

”在此处输入图像描述”

“

ASP.NET MVC error 403 forbidden Microsoft-Azure-Application-Gateway/v2

  • I have followed the given document and able to login , logout and re-login again without any issues, by changing few settings in Azure Active Directory
  • Navigate to Azure Portal => Azure Active Directory => Your Registered App => Authentication => Add Platform
  • Click on the Add Paltform => Select Web => Add Redirect URIs and Front-channel logout URL
  • Under Implicit grant and hybrid flows,make sure ID tokens checkbox is selected => Configure

enter image description here

enter image description here

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文