With Windows Integrated authentication, regardless of whether IIS or IIS Express is used, a 401 error may occur when accessing the same domain, with the wrong approach:
1. IIS (excerpted from MSDN)
IIS 7 was difficult for figuring out why I am getting the 401-unauthorized:access is denied due to invalid credentials ... until I did this ...
1.) Open IIS and select the website is causing the 401
2.) Open the "Authentication" property under the "IIS" header
3.) Click the "Windows Authentication" item and click "Providers"
4.) For me the issue is that Negotiate is above NTLM. I assume that there is some kind of handshake going on behind the scenes, but I was never really authenticated. I moved the NTLM to the top most spot, and BAM that fixed it.
2.IIS Express
The corresponding IIS express you must find its configuration file:C:\Users\v-xiaofz\Documents\IISExpress\config\applicationhost.config
Then set the following:
<authentication>
<anonymousauthentication enabled= "false" Username= ""/>
<basicauthentication enabled= "false"/>
<clientcertificatemappingauthentication enabled= "false"/>
<digestauthentication enabled= "false"/>
<iisclientcertificatemappingauthentication enabled= "false" >
</iisclientcertificatemappingauthentication>
< windowsauthentication enabled= "true" >
< providers>
<add value= "NTLM"/>
< add value= "Negotiate"/>
</providers>
</windowsauthentication>
</authentication>
The red section above is critical, with 401 errors because of the two switching positions.