Search code examples
c#asp.netiiswindows-authenticationiis-express

Using Windows Authentication in ASP.NET


I'm trying to use Windows Authentication in my ASP.NET application. Whenever I try to view the app it sends me to a login page. How can I make it work without having to manually login via the browser?

web.config

  <system.web>
    <authentication mode="Windows"></authentication>
    <anonymousIdentification enabled="false"/>
    <authorization>
      <deny users="?" />
      <allow users="*" />
    </authorization>
    <customErrors mode="Off"></customErrors>
    <identity impersonate="true"></identity>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime />
  </system.web>

error after updating IIS Express

Most likely causes:
No authentication protocol (including anonymous) is selected in IIS.
Only integrated authentication is enabled, and a client browser was used that does not support integrated authentication.
Integrated authentication is enabled and the request was sent through a proxy that changed the authentication headers before they reach the Web server.
The Web server is not configured for anonymous access and a required authorization header was not received.
The "configuration/system.webServer/authorization" configuration section may be explicitly denying the user access.

applicationhost.config

<authentication>
  <anonymousAuthentication enabled="false" />
  <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>

Solution

  • I was able get it working by removing the negotiate provider.

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