Site icon port135.com

Infinite redirect loop to login page in ASP.NET

When you try to view your webpage, you may run into this error:

HTTP Error 404.15 – Not Found
The request filtering module is configured to deny a request where the query string is too long.

Cause

This problem occurs if you:

Following solution will help you to sort this problem out without changing your configuration.

Solution

In order to get rid of this infinite loop, you can enable anonymous access. However, you may not want to enable it because of some security or functionality reasons such as getting users’ logon name. The other solution is that:

Add these lines into web.config file:

<system.webServer>
     <modules>
          <remove name="FormsAuthenticationModule" />
          <remove name="FormsAuthentication" />
     </modules>
</system.webServer>

Comment out these lines in App_Start/Startup.Auth.cs:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});

app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
Exit mobile version