Search code examples
.nethttpapplicationhost

Suddenly getting: The HTTP request is unauthorized with client authentication scheme 'Negotiate'


During a debugging session of a dotnet framework application I started getting:

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM,Basic realm=...

after launching the web project successfully for hours on IIS.

My .vs/{solutionName}/config/applicationhost.config has windows auth with negotiate:

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

Excatly the same settings for IIS:

C:\Program Files (x86)\IIS Express\AppServer\applicationhost.config

What could have happened to cause me to suddenly get this error?

i have tried clearing the cache for ie, but that did not work

Edit: I tried deleting the repo locally and cloning from remote, but this did not solve the issue, so there must be some local configuration outside of the repo that is causing this


Solution

  • This was quite the edge case.

    I had attempted to login to a web app, let's call it "BT", with incorrect credentials. This caused Credential Manager on Windows to create a Windows credential for BT with the wrong username+password combination.

    The project I am working on authorizes towards BT during launch which resulted in the error. I do not understand how, but apparently the credentials in Credential Manager were used instead of the default "use the logged in users credentials". The solution in my case was to modify/delete the windows credential in the Credential Manager