54408 (5) [Avatar] Offline
Great book, the only thing that seems wrong to me is the use of a disposed HttpClient in the example code.
using (var client = new HttpClient()) {

From the documentation for HttpClient:
HttpClient is intended to be instantiated once and re-used throughout the life of an application. Instantiating an HttpClient class for every request will exhaust the number of sockets available under heavy loads. This will result in SocketException errors. Below is an example using HttpClient correctly

See: https://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.110).aspx for the full documentation.

There is a good write up on what happens if you don't use a static HttpClient for your application at https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong

Is there a reason that you don't use a static HttpClient in your examples?

Dustin Metzgar (25) [Avatar] Offline
No, it's just a total miss on my part. Thanks for pointing this out! The book is currently in production but I'll see if we can get the examples fixed.