[Redirect] How you should (not) use HttpClient

By João Antunes

- 1 minutes read - 91 words

(The redirect tag in the title means this post is just a share of another post)

So, how do you use the HttpClient (.NET)? Like this?

1using (var client = new HttpClient())
3    var result = await client.GetAsync("");
4    //...

Well, so do I. And it’s wrong.

Check out this article that tells you all about why. tl;dr Use a singleton instance. Oh, and after that one, this is also a good (important) related read. (You’ll see that this second article makes my tl;dr a bit too short)


Categories: dotnet redirect
Tags: dotnet httpclient