question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider replacing WebClient with HttpClient in Metadataservice

See original GitHub issue

and maybe add using statements.

Also add optional support for the RP to provider their own instance of HTTPClient (because of socket control?).

Reasons to do this are listed in this SO answer: https://stackoverflow.com/questions/20530152/deciding-between-httpclient-and-webclient

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
abergscommented, Feb 14, 2019

Just briefly checked the commit.

We should really not block with .Result. See Sync over Async: https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AsyncGuidance.md#avoid-using-taskresult-and-taskwait

1reaction
CodeTherapistcommented, Feb 1, 2019

@aseigler Hmm, that’s strange! just try to build it (perhaps dotnet restore does also help).

@abergs Creating always a new instance of the HttpClient with using statement isn’t a good idea. HttpClient is intended to be instantiated once and reused throughout the life of an application - see docs and this blog post.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Replace WebClient with HttpClient?
Injecting HttpClient would be a better idea if possible HttpClient client = new(); string page = await client.GetStringAsync("page URL here");.
Read more >
When to use WebClient vs. HttpClient vs. HttpWebRequest
However, you should be aware that HttpClient was never designed to be a replacement for WebClient. You should use HttpWebRequest instead of  ......
Read more >
Sending HTTP requests with Spring WebClient
As part of this, Spring 5 introduced the new WebClient API, replacing the existing RestTemplate client. Using WebClient you can make ...
Read more >
WebRequest, WebClient, and ServicePoint are obsolete - . ...
Learn about the breaking change in .NET 6 where WebRequest, WebClient, and ServicePoint are deprecated in favor of HttpClient.
Read more >
Spring 5 WebClient
In this tutorial, we're going to examine WebClient, which is a ... module and will be replacing the classic RestTemplate in these scenarios....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found