HTTP Error 401.2 - Unauthorized for new site in a working app pool

23,652

Solution 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.

Solution 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
Share:
23,652
Splendor
Author by

Splendor

Updated on April 15, 2020

Comments

  • Splendor
    Splendor about 4 years

    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?

  • Danimal111
    Danimal111 over 10 years
    stackoverflow.com/questions/4762538/… -- This does the same for the application and no need to change global settings... do it in the application (and if you do it globally, but not in your VS app, it doesn't help as the local application setting overrides the global setting.