简体   繁体   中英

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

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.

在此处输入图像描述

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.

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 Director y => 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

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM