I am trying to understand the reason for the differences in two articles describing the same thing (calling a JSON rest webservice).
Article 1: Calling a Web API From a .NET Client in ASP.NET Web API 2
Article 2: Calling ASP.NET WebAPI using HttpClient
The differences are:
HttpResponseMessage response = await client.GetAsync("api/products/1");
vs
HttpResponseMessage response = client.GetAsync(url).Result;
and
Product product = await response.Content.ReadAsAsync>Product>();
vs
var users = response.Content.ReadAsAsync<Users>().Result;
My confusion is not with the asynchronous nature of the calls and I understand the functionality of the await statement. My confusion stems from the .Result at the end of the CodeProject examples (BTW the Code Project examples work for me) and the fact that the Microsoft article does not have them.
If I copy the Microsoft article code I get compiler warnings wanting me to add Task around my return type. What am I missing?
Thanks