So apparently HttpClient only allows for Asnyc calls?
Of course you can call ".Result" like so:
public ActionResult Index()
{
var someImportantData = httpClient.ReadAsStringAsync().Result; // Aparently I shouldn't do this according to the article.
// or
var someImportantData = Task.Run(() => Client.PostAsync()).Result;
Return View( new MyViewModel(someImportantData));
}
to make it synchronous but this is apparently very dangerous and should be avoided because it causes deadlocking as described here.
So what are my options for Synchronous requests? I'm I going to be force to use the older HttpWebRequest? In my specific MVC action I want the call to be synchronous as I don't want to return the page until I collect data from a restful api call.