title: .NET Core 3.1 User.Identity.Name always null with Windows Authentication
body: <p>I am using Windows Authentication with a .net core 3.1 application.  I would like to retrieve the current user name but it's always null.  I have not been able to deploy this application to IIS yet so this is happening while debugging with IISExpress.</p>
  <p>launchSettings.json:</p>
  <pre><code>{
    &quot;iisSettings&quot;: {
      &quot;windowsAuthentication&quot;: true,
      &quot;anonymousAuthentication&quot;: false,    
      &quot;iisExpress&quot;: {
        &quot;applicationUrl&quot;: &quot;http://localhost:52362&quot;,
        &quot;sslPort&quot;: 0
      }
    },
    &quot;profiles&quot;: {
      &quot;IIS Express&quot;: {
        &quot;commandName&quot;: &quot;IISExpress&quot;,
        &quot;launchBrowser&quot;: true,
        &quot;environmentVariables&quot;: {
          &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Development&quot;
        }
      }
    }
  }
  </code></pre>
  <p>Startup.cs:</p>
  <pre><code>public void ConfigureServices(IServiceCollection services)
          {
              services.AddAuthentication(IISDefaults.AuthenticationScheme);
              services.AddAuthorization();
  
              services.AddHttpContextAccessor();
              services.AddMvc();
              services.AddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt;();
          }
          
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              app.UseAuthentication();
              app.UseRouting();
              app.UseAuthorization();
          }
  </code></pre>
  <p>Controller:</p>
  <pre><code>[Authorize]
  [ApiController]
  [Route(&quot;[controller]&quot;)]
  public class FilingController : Controller
  {
      private readonly string _currentUserName;
      public FilingController(IHttpContextAccessor accessor)
      {
          //This is always null
          _currentUserName = accessor.HttpContext.User.Identity.Name;
      }
  }
  </code></pre>
  <p>Here is the Program.cs:</p>
  <pre><code>public class Program
      {
          public static void Main(string[] args)
          {
              CreateHostBuilder(args).Build().Run();
          }
  
          public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
              Host.CreateDefaultBuilder(args)
                  .ConfigureWebHostDefaults(webBuilder =&gt;
                  {
                      webBuilder.UseStartup&lt;Startup&gt;();
                      webBuilder.UseIISIntegration();
                      webBuilder.UseIIS();
                  });
      }
  </code></pre>
  <p>This occurs after a successful login.  Why is the Name null, how can this be fixed?</p>