This guide explores advanced best practices for using `HttpClient` in C#. It covers the creation of `HttpClient` instances using various methods like constructors, static instances, `IHttpClientFactory`, named, typed, and generated clients. The article also discusses middleware techniques, resilient handling of HTTP requests using timeout, retries, and circuit-breakers, and efficient ways to issue requests and handle responses while optimizing performance to avoid common pitfalls like port exhaustion and DNS changes.

21m read timeFrom medium.com
Post cover image
Table of contents
Making HttpClient resilientRequest TimeoutRetriesCircuit-BreakerFinishing The Resiliency Pipeline
3 Comments

Sort: