Last post Apr 27, 2015 02:08 PM by tjg5_99
Apr 27, 2015 10:35 AM|tjg5_99|LINK
Newbie question: what application types or VS2013 project types are required to use HttpClient?
I created a console app that makes a PostAsJsonAsync() call with no problems and returns the expected data.
The same code, in a VS2013 ASP.NET 4.5 web application project with Web API core folders and files included compiles and runs, but at the PostAsJsonAsync call (below), the
var response = await client.PostAsJsonAsync("Screen", request);
app becomes non-responsive. It does not freeze, but I cannot debug anything after this line. It's out in LaLa land.
Before I continue trying to debug, are there special requirements to using HttpClient?
I am referencing System.Net.Http and .HttpHeaders, and have installed the http client code from NuGet.
Looking online, the sample apps I see are either MVC or Console. Do I need to go with MVC or Console?
Apr 27, 2015 02:08 PM|tjg5_99|LINK
Figured it out!
My call needed to be:
response = await client.PostAsJsonAsync("Screen", request).ConfigureAwait(false);
Once I added ConfigureAwait(false) the data came right back.
Thanks to http://kalkanotel.com/ for the tip.