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.
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="" />
Unlike IIS Server, IIS Express doesn't support Windows Authentication by default. You can enable the Windows Authentication in IIS Express by modifying the applicationhost. config under the “C:\Users[username]\Documents\IISExpress\config” directory.
Right-click the project in Solution Explorer and select Properties. Select the Debug tab. Clear the checkbox for Enable Anonymous Authentication. Select the checkbox for Enable Windows Authentication.
In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services. On the Select Role Services page of the Add Role Services Wizard, select Windows Authentication, and then click Next. On the Confirm Installation Selections page, click Install. On the Results page, click Close.
Be careful with the applicationhost.config modifications - in Visual Studio 2015 I've found that it sometimes resides in the local project directory.
Note: The ".vs" folder is Hidden by default so you may have to select to show "Hidden Items" in Explorer to see it.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With