Why is HttpClient's GetStringAsync is unbelivable slow?

Posted by Jason94 on Stack Overflow See other posts from Stack Overflow or by Jason94
Published on 2013-11-09T21:49:40Z Indexed on 2013/11/09 21:53 UTC
Read the original article Hit count: 1574

I have a Windows Phone 8 project where I've taken to use the PCL (Portable Class Library) project too since I'm going to build a Win8 app to.

However, while calling my api (in Azure) my HttpClient's GetStringAsync is so slow. I threw in a couple of debugs with datetime and GetStringAsync took like 14 seconds! And sometimes it takes longer.

What I'm doing is retrieving simple JSON from my Azure API site. My Android client has no problem with getting that same data in a split second... so is there something I'm missing?

The setup is pretty straight forward:

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("X-Token", "something");
string responseJSON = await client.GetStringAsync("url");

I've places the debug times right before and after the await there, in between it is 14 seconds!

Does someone know why?

© Stack Overflow or respective owner

Related posts about c#

Related posts about windows-phone-8