title: Can't login after adding configure application cookies
body: <p>I'm developing Asp.Net Core 3.1 MVC web application with Identity. My login page works fine but after adding the <code>services.ConfigureApplicationCookie</code> it not worked as expected and it keeps redirecting me to my local index. I can't figure out what really happen. If I comment this block, everything works as expected.</p>
  <p>Here is my ConfigureServices method in <strong>Startup</strong> file</p>
  <pre><code> // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
  
          services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
             options.UseSqlServer(
                 Configuration.GetConnectionString(&quot;DefaultConnection&quot;)));
  
          services.AddIdentity&lt;IdentityUser, IdentityRole&gt;(options =&gt; {
              options.SignIn.RequireConfirmedAccount = false;
          })
              .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
              .AddDefaultTokenProviders();
  
          services.AddIdentityCore&lt;ApplicationUser&gt;()
              .AddRoles&lt;IdentityRole&gt;()
              .AddClaimsPrincipalFactory&lt;UserClaimsPrincipalFactory&lt;ApplicationUser, IdentityRole&gt;&gt;()
              .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
          //.AddDefaultTokenProviders() 
          .AddDefaultUI();
  
          services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
  
          services.ConfigureApplicationCookie(options =&gt;
          {
              options.Cookie.Name = &quot;.ExpirationCookie&quot;;
              options.Cookie.IsEssential = true;
              options.Cookie.HttpOnly = true;
              options.LoginPath = &quot;/Identity/Pages/Account/Login&quot;;
              options.AccessDeniedPath = &quot;/Identity/Pages/Account/AccessDenied&quot;; 
              options.ExpireTimeSpan = TimeSpan.Zero;
              options.SlidingExpiration = true;
              options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
              options.Events = new CookieAuthenticationEvents
              {
                  OnValidatePrincipal = ValidateAsync.ValidatingAsync
              };
          })
          .Configure&lt;SecurityStampValidatorOptions&gt;(options =&gt;
          {
              options.ValidationInterval = TimeSpan.Zero;
          });
  
          services.AddSingleton&lt;IEmailSender, EmailSender&gt;();
          services.Configure&lt;EmailOptions&gt;(Configuration);
          services.AddHangfire(config =&gt; config.UseSqlServerStorage(Configuration.GetConnectionString(&quot;DefaultConnection&quot;)));
          services.AddHangfireServer();
          services.AddControllersWithViews(); //?
          services.AddRazorPages().AddRazorRuntimeCompilation(); //?
          services.AddScoped&lt;IExpirationJob, ExpirationJob&gt;();
          services.AddScoped&lt;IReminderJob, EmailReminder&gt;();
          services.AddSingleton&lt;IActionContextAccessor, ActionContextAccessor&gt;();
          services.Configure&lt;IdentityOptions&gt;(options =&gt;
          {
              // Password settings.
              //options.Password.RequireDigit = true;
              //options.Password.RequireLowercase = true;
              //options.Password.RequireNonAlphanumeric = true;
              //options.Password.RequireUppercase = true;
              //options.Password.RequiredLength = 6;
              //options.Password.RequiredUniqueChars = 1;
              // Lockout settings.
              //options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
              //options.Lockout.MaxFailedAccessAttempts = 5;
              //options.Lockout.AllowedForNewUsers = true;
              // User settings.
              //options.User.AllowedUserNameCharacters =
              //    &quot;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+ &quot;;
              //options.User.RequireUniqueEmail = false;
          });
      }
  </code></pre>