Windows Authentication not working in IIS Express, debugging with Visual studio 2013, Windows 8

Hiren picture Hiren · Jun 13, 2014 · Viewed 46.6k times · Source

I just upgraded my application from Visual studio 2012 to Visual studio 2013. My windows authentication is not working any more. It is giving me below error.

     HTTP Error 401.2 - Unauthorized
     You are not authorized to view this page due to invalid authentication headers.

In visual studio there is option to select authentication from website properties itself. So I disabled anonymous access and enable windows authentication but it is asking me for username and password as below popup. Even if I give domain credentials here. Its is still giving me this popup again and again.

enter image description here enter image description here

Web Config :

     <authentication mode="Windows" />
     <authorization>
     <deny users="?" />
     </authorization>
     <identity impersonate="false" />
     <trace enabled="true" />

IIS Express aspnetConfig :

     <authentication>

            <anonymousAuthentication enabled="false" userName="" />

            <basicAuthentication enabled="false" />

            <clientCertificateMappingAuthentication enabled="false" />

            <digestAuthentication enabled="false" />

            <iisClientCertificateMappingAuthentication enabled="false">
            </iisClientCertificateMappingAuthentication>

            <windowsAuthentication enabled="true">
                <providers>
                    <add value="Negotiate" />
                    <add value="NTLM" />
                </providers>
            </windowsAuthentication>

        </authentication>

        <authorization>
            <add accessType="Allow" users="*" />
        </authorization>



        <location path="Path">
        <system.webServer>
        <security>
            <authentication>
                <windowsAuthentication enabled="true" />
                <anonymousAuthentication enabled="false" />
            </authentication>
        </security>
        </system.webServer>
        </location>

Let me know if you want more details on this.

Update :

I found out that if I remove below line from web.config than it start working.

     <remove users="*" roles="" verbs="" />

Answer

Coruscate5 picture Coruscate5 · Jul 15, 2016

Be careful with the applicationhost.config modifications - in Visual Studio 2015 I've found that it sometimes resides in the local project directory.

For example:

DRIVE:\MYPROJECT\.vs\config\applicationhost.config

If you're not sure which applicationhost config file is being used, you can monitor file access with ProcMon & then narrow down the results based on "Path" to see what VS is actually reading at Debug time.

Update: This appears to be the behavior in Visual Studio 2017 as well.