title: ASP.NET Authentication Issues on IIS7 - User.Identity.Name is empty for Windows authentication
body: <p>We have an ASP.NET application on ASP.NET 4.0 using MVC 3 which uses Windows authentication.</p>
  
  <p>When run from Visual Studio 2010 everything works as expected but when rolled out to IIS7 the Windows logged in user never gets populated (checking User.Identity.Name). No dialog prompt for user credentials comes up either.</p>
  
  <p>The web.config setting:</p>
  
  <pre><code>&lt;authentication mode="Windows" /&gt;
  </code></pre>
  
  <p>In IIS I can see that Windows authentication is enabled, as is Anonymous (disabling Anonymous results in a 403 Forbidden and no content being shown).</p>
  
  <p>I've tried both enabling and disabling "Kernel-mode authentication" (useKernelMode="true"), but this doesn't seem to make any difference. Though I do remember that we had to disable this setting on another site on a different server to get the authentication to work properly (might point to a potential issue further down the stack?).</p>
  
  <p>In case it's useful, from IIS's applicationHost.config:</p>
  
  <pre><code>&lt;security&gt;
    &lt;authentication&gt;
      &lt;anonymousAuthentication enabled="true" /&gt;
      &lt;digestAuthentication enabled="false" /&gt;
      &lt;basicAuthentication enabled="false" /&gt;
      &lt;windowsAuthentication enabled="true" useKernelMode="false"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add value="NTLM" /&gt;
        &lt;/providers&gt;
      &lt;/windowsAuthentication&gt;
    &lt;/authentication&gt;
  &lt;/security&gt;
  </code></pre>
  
  <p>Any ideas what the issue could be?</p>
  
  <p>Thanks in advance for any suggestions.</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>I managed to find another IIS7 server to test on and I found if I disabled Anonymous access everything worked as desired. However I still have issues on the original IIS7 server even when I disable Anonymous access as well (I'm keeping Anonymous disabled now). So there must be some issue further down the stack I guess. Any ideas? Something I need to fix as it's going to keep popping up and biting us I imagine.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>If I enable Digest Authentication on the problem IIS7 box then I am challenged with the login prompt dialog and everything works as expected if I provide suitable credentials. But being an internal web app with users already logged in to the domain we don't really want to challenge them this way. Credentials should be passed through transparently as it works on the second IIS7 box.</p>
  
  <p><strong>Update 3</strong></p>
  
  <p>Some progress... I've found that if the web app is in the root and not a sub site then directly editing the applicationHost.config file for IIS7 to give the following authentication settings allows the site to work as expected:</p>
  
  <pre><code>&lt;authentication&gt;
    &lt;anonymousAuthentication enabled="false" /&gt;
    &lt;windowsAuthentication enabled="true"&gt;
      &lt;providers&gt;
        &lt;clear /&gt;
        &lt;add value="NTLM" /&gt;
      &lt;/providers&gt;
    &lt;/windowsAuthentication&gt;
    &lt;digestAuthentication enabled="false" /&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p>Using IIS7's UI to configure the authentication doesn't give quite the right results. authentication items are either missing after wards (as I guess IIS7 assumes they are being inherited) or they have the wrong settings (windowsAuthentication seems to need the providers configuration above present to work correctly).</p>
  
  <p>Unfortunatly the web application in question is actually a sub application as there's an internal version (using windows authentication > www.site.com/internal) and an external version (using forms authentication > www.site.com/external). I still can't get the authentication to work as a sub application yet. I just get a "Error Code: 403 Forbidden".</p>