So, apparently, HttpClient only allows Asnyc calls?
Of course, you can call ".Result" like this:
public ActionResult Index()
{
var someImportantData = httpClient.ReadAsStringAsync().Result;
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 as it causes a dead end, as described here.
So what are my options for synchronous queries? Am I going to use the power of the old HttpWebRequest? In my specific MVC action, I want the call to be synchronous, since I don't want to return the page until I collect the data from the calm api call.
source
share