I am following Cookie Middleware to add authentication for my simple web application.
I have added the below code in startup.cs Configure method.
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "Cookies",
LoginPath = new PathString("/Account/Login/"),
AccessDeniedPath = new PathString("/Account/Error/"),
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
When i accessing /Home, it redirects to /Account/Login but page doesn't open and getting error message as
The localhost page isn’t working : localhost redirected you too many times.
The url appends with same login page many times and look like
What i did wrong? Help me to solve this.
This is because your /Account/Login
action also requires login, which causes an infinite redirect loop. Add AllowAnonymousAttribute
on this action.