Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Confusing doc about HttpClient Disposables #46020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
deleteLater opened this issue May 6, 2025 · 0 comments · Fixed by #46026
Closed

Confusing doc about HttpClient Disposables #46020

deleteLater opened this issue May 6, 2025 · 0 comments · Fixed by #46026
Assignees
Labels
dotnet-fundamentals/svc 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@deleteLater
Copy link

deleteLater commented May 6, 2025

Type of issue

Missing information

Description

  1. https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory

    The code examples in this article dispose the HttpClient returned from httpClientFactory.CreateClient(), and it says

    Disposing of such HttpClient instances created by the factory will not lead to socket exhaustion...

  2. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-9.0&preserve-view=true#httpclient-and-lifetime-management

    The code example in this article not dispose the HttpClient returned from httpClientFactory.CreateClient(), and it says

    HttpClient instances can generally be treated as .NET objects not requiring disposal...

  3. https://learn.microsoft.com/en-us/dotnet/api/system.net.http.ihttpclientfactory.createclient?view=net-9.0-pp#remarks

    The remark says

    It is generally not necessary to dispose of the HttpClient as the IHttpClientFactory tracks and disposes resources used by the HttpClient

So shall we dispose the HttpClient returned by httpClientFactory.CreateClient()?

Page URL

https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/extensions/httpclient-factory.md

Document Version Independent Id

33db41be-42f9-bb94-65fe-0cf7d1c64f12

Platform Id

c667850f-a5ec-d80b-d8af-0c1c1e37e599

Article author

@IEvangelist

Metadata

  • ID: 46af0b96-2d12-9cac-2f8f-15eb49d0292d
  • PlatformId: c667850f-a5ec-d80b-d8af-0c1c1e37e599
  • Service: dotnet-fundamentals

Related Issues


Associated WorkItem - 429408

@dotnet-policy-service dotnet-policy-service bot added the ⌚ Not Triaged Not triaged label May 6, 2025
@IEvangelist IEvangelist self-assigned this May 6, 2025
@IEvangelist IEvangelist added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label May 6, 2025
@dotnet-policy-service dotnet-policy-service bot removed the ⌚ Not Triaged Not triaged label May 6, 2025
@dotnetrepoman dotnetrepoman bot added the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label May 6, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label May 6, 2025
@github-project-automation github-project-automation bot moved this from 🔖 Ready to ✅ Done in dotnet/docs May 2025 sprint project May 6, 2025
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fundamentals/svc 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants