问题
I am deploying a new EF 4.0 ASP.NET MVC 4 site to an IIS 7.0 server but I'm getting an error that says:
"HTTP Error 401.2 - Unauthorized You are not authorized to view this page due to invalid authentication headers."
I have Anonymous Authentication and Forms Authentication disabled. ASP.NET Impersonation and Windows Authentication are both enabled.
I've confirmed that everything okay according to this Microsoft KB article
Even better, there is already a working site in the same app pool using the same type of authentication.
I'm not sure what to check next. Does anyone have an idea what's causing this error?
回答1:
I figured it out. I had to add this to my applicationHost.config file (located in the windows/system32/inetsrv/config folder).
<windowsAuthentication enabled="true">
<providers>
<add value="Negotiate" />
<add value="NTLM" />
</providers>
</windowsAuthentication>
It was there for the other working application but not this new one.
回答2:
On a recently built 2012R2 web server I kept running in to this error even for simple cases. I finally fixed it by reinstalling the Windows Authentication feature.
PowerShell:
Remove-WindowsFeature Web-Windows-Auth
Add-WindowsFeature Web-Windows-Auth
来源:https://stackoverflow.com/questions/16902601/http-error-401-2-unauthorized-for-new-site-in-a-working-app-pool