How to pass DefaultCredentials in ASP.NET Core to the HttpClient?
It works fine when I run it locally in VisualStudio. The current user is authorized to request "www.mycompany.com". But as soon as I publish it to the IIS I get an 401 (Unauthorized) because HttpClient get the web-server-user (not authorized) in DefaultCredentials.
Windows-Authentification is active in VisualStudio and on IIS.
My c# code:
HttpClient Client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true });
Client.BaseAddress = new Uri("www.mycompany.com");
Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Client.DefaultRequestHeaders.Add("Application-Name", Assembly.GetExecutingAssembly().GetName().Name);
HttpResponseMessage response = Client.GetAsync("/classes").Result;
EDIT
I understand that locally it runs with current user, but I don't know how to authorize the Application Pool...
EDIT2
I didn't quite explain it correctly. I want to pass-trough the authentication from the local user to the HttpClient. Only local users are authorized to make a request