DEV Community

Ali Bayat
Ali Bayat

Posted on

Answer: HttpClientFactory.Create vs new HttpClient

IHttpClientFactory offers the following benefits:

  1. Naming and configuring logical HttpClient instances.
  2. Build an outgoing request middleware to manage cross-cutting concerns around HTTP requests.
  3. Integrates with Polly for transient fault handling.
  4. Avoid common DNS problems by managing HttpClient lifetimes.
  5. Adds logging for all requests sent through clients created by the factory.

Top comments (0)