dotnet / dotnet/AspNetCore.Docs

Can we keep using a single HttpClient from IHttpClientFactory?

Open
#19,354 6 comments 1 reaction 0 assignees View on GitHub
area-runtime-extensions doc-enhancement re-Aditya Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

I've read the documentation page a number of times.

It states the following:

> Using IHttpClientFactory in a DI-enabled app avoids:
> - Resource exhaustion problems by pooling HttpMessageHandler instances.
> - Stale DNS problems by cycling HttpMessageHandler instances at regular intervals.

Does that mean that if I have a singleton service, that has a **typed** `HttpClient` registered to it, the `HttpClient` will have its `HttpMessageHandler` recycled, avoiding Stale DNS problems and resource exhaustion?

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 881cef77-11ef-ac11-06d0-0996a1ccfa1b
* Version Independent ID: 3d356334-e672-7e8b-1fef-7944ebee99eb
* Content: [Make HTTP requests using IHttpClientFactory in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1#named-clients)
* Content Source: [aspnetcore/fundamentals/http-requests.md](https://github.com/dotnet/AspNetCore.Docs/blob/master/aspnetcore/fundamentals/http-requests.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-fundamentals**
* GitHub Login: @stevejgordon
* Microsoft Alias: **scaddie**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.