Skip to content
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

Update static usage remarks #7833

Closed
wants to merge 2 commits into from
Closed

Update static usage remarks #7833

wants to merge 2 commits into from

Conversation

rasitha1
Copy link

@rasitha1 rasitha1 commented Mar 16, 2022

Summary

Static usage is not the only best option and can be problematic for long running apps. Provide awareness of the HttpClientFactory to the reader and other safe ways of instantiating HttpClient along with using DI.

Fixes #1326

Static usage is not the only best option and can be problematic for long running apps. Provide awareness of the `HttpClientFactory` to the reader and other safe ways of instantiating HttpClient along with using DI.

#1326
@ghost
Copy link

ghost commented Mar 16, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Summary

Static usage is not the only best option and can be problematic for long running apps. Provide awareness of the HttpClientFactory to the reader and other safe ways of instantiating HttpClient along with using DI.

Fixes dotnet/docs#1327

Author: rasitha1
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@opbld33
Copy link

opbld33 commented Mar 16, 2022

Docs Build status updates of commit 0ca56b0:

✅ Validation status: passed

File Status Preview URL Details
xml/System.Net.Http/HttpClient.xml ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@CarnaViire
Copy link
Member

Hi @rasitha1
The team's current view is that HttpClientFactory is not a recommended way for a general case. Especially if the app doesn't use DI and has no need in it.
The recommended way to overcome DNS problems is to use PooledConnectionLifetime property of SocketsHttpHandler.
Unfortunately the latter is not well advertised in the moment.
We have an issue in our pipeline to rework current HttpClient documentation: dotnet/docs#26510. Please feel free to discuss your suggestion in that issue.

@CarnaViire CarnaViire closed this Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify between "only a single instance should be created for an entire application" and "derived classes"
3 participants