1

issue in .net 5 that not happen in .net core 3.1 the windows authentication didn't pass to HttpClient

this same code that work on .net core 3.1 :

[HttpGet("getuser")]
public async Task<ActionResult> GetUser()
{
   var handle = new HttpClientHandler
   {
     Credentials = CredentialCache.DefaultCredentials,
     //UseDefaultCredentials = true, //=> try this too
     AllowAutoRedirect = true,
    };
    var httpclient = new HttpClient(handle);
    var res = await httpclient.GetAsync("http://service/rest/getcurrentuser"); //get 401
    var result = await res.Content.ReadAsStringAsync();
    return Ok(result);
  }




         
kfir
  • 21
  • 3
  • I'm experiencing the same issue. I'm trying to query existing mvc web api hosted on IIS, but without success (401). But for me it's even not working when switching to dotnet 3.1. The only difference is I'm registering the HttpClient in Startup.cs. – Mozartos Jul 01 '21 at 15:23

0 Answers0