This post shows you how to solve 'LoginPath not working in ASP.NET Core'.
By default, if you don't configure it's automatically redirect to "/Account/Login?RedirectUrl=%2F"
Opening your Startup class, then add a configuration as shown below.
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = new PathString("/Identity/Account/Login");
options.ReturnUrlParameter = "RedirectUrl";
options.LogoutPath = new PathString("/Identity/Account/Lockout");
options.AccessDeniedPath = new PathString("/Identity/Account/AccessDenied");
options.ExpireTimeSpan = TimeSpan.FromDays(1);
});
instead of use services.AddAuthentication().AddCookie
services.AddAuthentication().AddCookie(options =>
{
options.LoginPath = "/Identity/Account/Login";
options.ExpireTimeSpan = TimeSpan.FromDays(1);
});