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.