I am trying to make an HTTP GET call from a .NET Core 3.0 console application. The endpoint expects Windows Authentication. The endpoint is an in-production .NET Framework 4.5.2
So we are running into the same issue with HttpClient, but on the first request it is unauthorized, but if we do a another quick request call, it goes through just fine, and we get authorized.
If I do this on a .NET 4.7.1 console app, it works perfect. If I do it in a .NET 4.7.1 empty web app, it works fine, only if I do .NET Core 2.x do we get this issue.
var result = string.Empty;
var responseMessage = _client.GetAsync(url).Result;
if (responseMessage.IsSuccessStatusCode)
{
result = await responseMessage.Content.ReadAsStringAsync();
}
else
{
var responseMessage2 = _client.GetAsync(url).Result;
if (responseMessage2.IsSuccessStatusCode)
{
result = await responseMessage2.Content.ReadAsStringAsync();
}
}
return result;