title: ASP.NET Core 3.1 [Authorize] attribute redirects to login even for logged in user
body: <p>Ihave an ASP.NET Core sandbox project.
  I have added <code>IdentityDbContext</code>.
  Registration page works correct. Login/Logout pages work correct. (It can be seen by html that is shown for <code>SignInManager.IsSignedIn(User)</code> users)</p>
  <p>I have a controller marked with <code>[Authorize]</code>:</p>
  <pre><code>[Authorize]
  public class MyTestController : Controller
  {
      ...
  }
  </code></pre>
  <p>When I try to navigate to it for the first time - it works correct (redirects to login page)</p>
  <p><strong>But after successful login it redirect again back to login with the same link: <code>https://localhost:44359/Identity/Account/Login?ReturnUrl=%2FMyTest</code></strong></p>
  <p>Here is my code from <code>Startup.cs</code>:</p>
  <pre class="lang-cs prettyprint-override"><code>        // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddControllersWithViews().AddRazorRuntimeCompilation();
              services.AddRazorPages().AddRazorRuntimeCompilation();
              services.AddControllers().AddNewtonsoftJson(options =&gt;
              {
                  // Use the default property (Pascal) casing
                  options.SerializerSettings.ContractResolver = new DefaultContractResolver();
              });
  
              services.AddDbContext&lt;MyAppContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString(&quot;Default&quot;)));
              services.AddDefaultIdentity&lt;IdentityUser&gt;(options =&gt;
                  {
                      options.Password.RequireDigit = false;
                      options.Password.RequireLowercase = false;
                      options.Password.RequireNonAlphanumeric = false;
                      options.Password.RequireUppercase = false;
                  })
                  .AddEntityFrameworkStores&lt;MyAppContext&gt;();
  
              services.AddAuthorization();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler(&quot;/Home/Error&quot;);
                  // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                  app.UseHsts();
              }
              app.UseHttpsRedirection();
              app.UseStaticFiles();
  
              app.UseRouting();
  
              app.UseAuthorization();
              app.UseAuthentication();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllerRoute(
                      name: &quot;default&quot;,
                      pattern: &quot;{controller=Home}/{action=Index}/{id?}&quot;);
                  endpoints.MapRazorPages();
              });
          }
  </code></pre>
  <p>Previously I have added scaffolded identity items for Login, Logout, Register.
  Controller without <code>[Authorize]</code> works good.</p>