httpclient-factory

Configure named, typed, and keyed HttpClient instances with resilience in .NET 10.

640|145|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/codewithmukesh/dotnet-claude-kit --skill httpclient-factory
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: httpclient-factory
Source: https://github.com/codewithmukesh/dotnet-claude-kit/tree/main/skills/httpclient-factory
Command: npx skills add https://github.com/codewithmukesh/dotnet-claude-kit --skill httpclient-factory

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

HTTP client usage in .NET apps often leads to socket exhaustion, brittle tests, and brittle configurations when HttpClient is created ad-hoc. This Skill shows how to use IHttpClientFactory to centralize and optimize HTTP calls.

Core Features & Use Cases

  • Configure named, typed, and keyed HttpClient instances with resilience in plain DI setups.
  • Implement DelegatingHandlers for cross-cutting concerns like auth tokens and correlation IDs, and test patterns for HTTP calls.
  • Use in API integrations, microservices, and external service consumption to ensure reliable, thread-safe HTTP access.

Quick Start

Register HttpClient via AddHttpClient and AddStandardResilienceHandler, then inject a named, typed, or keyed client into your services to enable robust, resilient HTTP calls.

Frequently Asked Questions about httpclient-factory

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

FAQPage Schema
Why does creating HttpClient directly cause socket exhaustion in .NET and how do I fix it?▼

Creating HttpClient directly causes socket exhaustion because sockets are not released promptly. Using IHttpClientFactory centralizes HTTP client creation, managing socket lifetimes and enabling robust HTTP calls.

How do I configure resilient HTTP clients in .NET 10 using IHttpClientFactory?▼

Register HTTP clients via AddHttpClient and apply AddStandardResilienceHandler in your DI setup. Then inject named, typed, or keyed clients into services to configure robust HTTP usage.

When should I use typed, named, or keyed HttpClient instances in .NET microservices?▼

Use named clients for basic configurations, typed clients for encapsulated API integrations, and keyed clients when you need to resolve specific clients dynamically within your .NET microservices.

How do I add authentication tokens and correlation IDs to outgoing HTTP requests in .NET?▼

Implement DelegatingHandlers to intercept outgoing HTTP requests. This approach adds cross-cutting concerns like authentication tokens and correlation IDs before the request reaches the network.

Can I use AddStandardResilienceHandler with keyed HttpClient instances in .NET 10?▼

Yes, AddStandardResilienceHandler applies resilience to HTTP clients configured via AddHttpClient. You can combine this with AddAsKeyed to expose resilient keyed clients for dynamic service resolution.

How do I test HTTP calls that use DelegatingHandlers and IHttpClientFactory?▼

Testing HTTP calls involves substituting the primary handler with a mock message handler. This preserves the DelegatingHandlers pipeline and IHttpClientFactory configuration for validating external service interactions.