I have the same code as below targeting .Net Framework 4.6.2 and .Net Core 5 but seems to yield different authentication behavior.
The .Net Framework version works fine with WWW-Authenticate: Negotiate
but the same code fails with the .Net Core version.
Here's the code snippet that I'm using for both.
var server = "https://www.example.com";
var client = new HttpClient(new HttpClientHandler { UseDefaultCredentials = true }) { BaseAddress = new Uri(server) };
var response = await client.GetAsync("/api/token");
var result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
And here's the entire failure response.
StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Cache-Control: no-cache
Pragma: no-cache
WWW-Authenticate: Negotiate
X-Powered-By: ASP.NET
Date: Fri, 02 Jul 2021 08:30:51 GMT
Content-Type: application/json; charset=utf-8
Expires: -1
Content-Length: 68
}
Is there anything else I missed in the .Net Core version?