title: User.Identity.Name is null in Asp.Net Core 2.x web application using Windows Authentication
body: <p><strong>Problem</strong></p>
  
  <p>When hosting an Asp.Net Core 2.0 or 2.1 Web Application behind IIS with Windows Authentication set to true, and Anonymous Authentication set to false, the <code>User.Identity.Name</code> property is null and <code>User.Identity.IsAuthenticated</code> is false.</p>
  
  <p>According to the documentation <a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-2.1" rel="nofollow noreferrer">here</a>, Windows Authentication should just work in Asp.Net Core 2.x when hosting with IIS.</p>
  
  <p><strong>Background</strong></p>
  
  <p>I'm in the process of migrating an Asp.Net 4.x MVC application over to Asp.Net Core following the <a href="https://docs.microsoft.com/en-us/aspnet/core/migration/mvc?view=aspnetcore-2.1" rel="nofollow noreferrer">Migrate from ASP.NET MVC to ASP.NET Core MVC guide</a>.</p>
  
  <p>I'm testing the site on a server that is currently hosting Asp.Net 4.x MVC applications that use Windows Authentication without issue. The Identity of the Windows user is available as expected.</p>
  
  <p>After completing the migration guide and fixing all build issues, I've created a "Local IIS" profile under "Debug" in the web project properties, setting the "Launch" option to "IIS". I've ticked only "Enable Windows Authentication" and then browsed to the website. Despite being logged in with valid domain credentials, <code>User.Identity.Name</code> is still null.</p>
  
  <p>I installed the .Net Core 2.1 SDK before starting the migration process and have previously installed the .Net Core 1.0.1 SDK Preview. The server is running Windows 2008 R2 with IIS 7.</p>
  
  <p><strong>What I've Tried</strong></p>
  
  <p>In order to ensure I hadn't introduced this problem during the migration process I created a new ASP.NET Core Web Applications, using the MVC template and targeting .NET Framework 4.7.2. I configured "Windows Authentication" when choosing the template. After confirming that Windows Authentication worked when using IIS Express, I configured Local IIS as above. When browsed to under IIS, the top right of the navigation bar shows "Hello, !". I tried this with templates from Asp.Net Core SDK 2.0 and 2.1.</p>
  
  <p>I've followed various guides and Stackoverflow answers all relating to configuring Windows Authentication within the Asp.Net Core application itself. Results have been either no change, or continuous login prompts that never accept a valid username and password. It appears these solutions may be written for older versions of the framework or scenarios where the developer is attempting to combine multiple authentication methods.</p>