title: SignInManager.IsSignedIn(User) method always returns false
body: <blockquote>
  <p>Here the if condition is always returning false even when - app.useAuthentication() middleware is used</p>
  <p>_Layout.cshtml</p>
  </blockquote>
  <pre><code>                @if (signInManager.IsSignedIn(User))
                  {
                      &lt;li class=&quot;nav-item&quot;&gt;
                          &lt;form method=&quot;post&quot; asp-controller=&quot;account&quot; asp-action=&quot;logout&quot;&gt;
                              &lt;button type=&quot;submit&quot; style=&quot;width:auto&quot;
                                      class=&quot;nav-link btn btn-link py-0&quot;&gt;
                                  Logout @User.Identity.Name
                              &lt;/button&gt;
                          &lt;/form&gt;
                      &lt;/li&gt;
                  }
                  else
                  {
                      &lt;li class=&quot;nav-item&quot;&gt;
                          &lt;a class=&quot;nav-link&quot; asp-controller=&quot;account&quot; asp-action=&quot;register&quot;&gt;
                              Register
                          &lt;/a&gt;
                      &lt;/li&gt;
                      &lt;li class=&quot;nav-item&quot;&gt;
                          &lt;a class=&quot;nav-link&quot; asp-controller=&quot;account&quot; asp-action=&quot;login&quot;&gt;
                              Login
                          &lt;/a&gt;
                      &lt;/li&gt;
                  }
  </code></pre>
  <blockquote>
  <p>Satrtup.cs</p>
  </blockquote>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using EmployeeManagementPractice.Modals;
  using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.AspNetCore.Http;
  using Microsoft.AspNetCore.Identity;
  using Microsoft.EntityFrameworkCore;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Hosting;
  
  namespace EmployeeManagementPractice
  {
      public class Startup
      {
          private IConfiguration _config;
  
          public Startup(IConfiguration config)
          {
              _config = config;
          }
          
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddAuthentication();
  
          services.AddIdentity&lt;IdentityUser, IdentityRole&gt;(options =&gt;
          {
              options.Password.RequiredLength = 8;
          }).AddEntityFrameworkStores&lt;AppDbContext&gt;();
  
  
          services.AddDbContextPool&lt;AppDbContext&gt;(
              options =&gt; options.UseSqlServer(_config.GetConnectionString(&quot;EmployeeDBConnection&quot;)));
  
          services.AddMvc(action =&gt; action.EnableEndpointRouting = false);
  
          services.AddScoped&lt;IEmployeeRepository, SQLEmployeeRepository&gt;();
      }
  
      // 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;/Error&quot;);
              app.UseStatusCodePagesWithReExecute(&quot;/Error/{0}&quot;);
          }
  
          app.UseStaticFiles();
          app.UseMvc(routes =&gt;
          {
              routes.MapRoute(&quot;default&quot;, &quot;{controller=home}/{action=index}/{id?}&quot;);
          });
          app.UseRouting();
          app.UseAuthentication();
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapGet(&quot;/&quot;, async context =&gt;
              {
                  await context.Response.WriteAsync(&quot;Hello World!&quot;);
              });
          });
          }
      }
  }
  </code></pre>
  <blockquote>
  <p>Whenever I run the mvc file in debug mode, the signInManager.IsSignedIn(User) is returning false even after correct Login Id and Password</p>
  <p>In the controller, in the Login Action- if (result.Succeeded) is returning true, Please help someone why signInManager.IsSignedIn(User) is returning false.</p>
  </blockquote>
  <pre><code>public async Task&lt;IActionResult&gt; Login(LoginViewModel model)
      {
          if (ModelState.IsValid)
          {
              var result = await signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, false);
              if (result.Succeeded)
              {
                  return RedirectToAction(&quot;index&quot;, &quot;home&quot;);
              }
              ModelState.AddModelError(&quot;&quot;, &quot;Invalid Login Password&quot;);
          }
          return View();
      }
  </code></pre>