dotnet-http-client

Configure IHttpClientFactory with typed clients, DelegatingHandlers, and resilience pipelines in .NET.

Updated Aug 16, 2025
One-click install
npx skills add https://github.com/dodyg/blue-nile-pds --skill dotnet-http-client-dodyg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-http-client
Source: https://github.com/dodyg/blue-nile-pds/tree/main/.agents/skills/dotnet-http-client
Command: npx skills add https://github.com/dodyg/blue-nile-pds --skill dotnet-http-client-dodyg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill documents best practices for consuming HTTP APIs in .NET to avoid socket exhaustion, DNS staleness, duplicated HTTP logic, and fragile retry implementations when calling external services.

Core Features & Use Cases

  • IHttpClientFactory patterns for named and typed clients to centralize configuration and lifetime management.
  • DelegatingHandler pipelines for cross-cutting concerns such as correlation IDs, bearer token propagation, API key injection, and request/response logging.
  • Resilience pipeline integration covering retries, hedging, attempt and total timeouts, and circuit breakers to make HTTP calls robust.
  • Testing guidance including unit tests with mock HttpMessageHandler and integration tests using DI and WebApplicationFactory.
  • Use Case: implement a typed CatalogApiClient that encapsulates API calls, composes DelegatingHandlers, and is protected by a standard resilience handler.

Quick Start

Register a typed CatalogApiClient with AddHttpClient, add transient DelegatingHandlers for correlation and bearer token propagation, and attach the standard resilience handler to protect outbound requests.

Frequently Asked Questions about dotnet-http-client

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent socket exhaustion when using HttpClient in .NET?

Prevent socket exhaustion in .NET by using IHttpClientFactory to manage HttpClient lifetimes, applying named or typed clients to centralize configuration and avoid DNS staleness when consuming external APIs.

What is the best way to configure retries and circuit breakers for .NET HTTP calls?

The best way to configure HTTP resilience is by integrating Microsoft.Extensions.Http.Resilience to apply retries, hedging, timeouts, and circuit breakers to outbound HTTP requests.

How do I add correlation IDs and bearer token propagation to .NET HTTP requests?

Add correlation IDs and bearer token propagation to HTTP requests by building a DelegatingHandler pipeline that injects cross-cutting concerns into your typed HTTP clients.

How do I unit test a typed HttpClient that uses DelegatingHandlers in .NET?

Unit test a typed HttpClient by mocking HttpMessageHandler to simulate API responses, and verify that DelegatingHandler chains correctly process cross-cutting concerns.

Does IHttpClientFactory support configurable handler lifetimes in .NET?

IHttpClientFactory supports configurable handler lifetimes in .NET, allowing you to set transient DelegatingHandlers and control the expiration of HTTP message handler pools.