4

I have HttpClient httpClient injected from outside of my class.

Inside my class I'm creating a new HttpClientHandler var handler = new HttpClientHandler() and setting its values.

I need to link HttpClientHandler to existing HttpClient the same way you can do it using the constructor: new HttpClient(handler)

Is it possible? I've tried looking for HttpClientHandler property within HttpClient but it does not exist. Is there any other way?

Mariusz Ignatowicz
  • 1,445
  • 2
  • 20
  • 41
  • Have you customized the `httpClient` instance you're injecting? – Muhammad Hannan Sep 11 '20 at 18:47
  • `Is it possible?` No. Using Httpclient factory however, a client can be configured to use a specific handler. https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests – Nkosi Sep 11 '20 at 18:53
  • This might be an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). Provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) that clarifies your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. – Nkosi Sep 11 '20 at 18:54

0 Answers0