A
A
Artem Skopintsev2014-04-20 18:59:55
.NET
Artem Skopintsev, 2014-04-20 18:59:55

Why does one code work fine in a WPF app, but the same code doesn't run in a Windows Store app?

Hello!
I'm writing a Windows Store app that has a point where a GET request needs to be sent. I wrote the same desktop application using WPF, everything worked fine. And now the same code is not running in the Windows Store app.
Here is the code itself:

WebRequest request = WebRequest.Create(uri);
WebResponse response = await request.GetResponseAsync();
Stream stream = response.GetResponseStream();
var sr = new StreamReader(stream);

It seems to execute the second line indefinitely. And no exception is thrown. Uri checked for correctness several times. At this time, the running application itself is in a "hanging" state.
Thank you all in advance for your replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RIAMedia, 2014-04-21
@RIAMedia

Try doing this:

HttpClient http = new System.Net.Http.HttpClient();
HttpResponseMessage response = await http.GetAsync(address);
await response.Content.ReadAsStringAsync();

This works in the Windows Store.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question