3
我想送与WP7 HttpWebRequest类的请求,但我没有得到任何回应... 这里是我的代码:如何从WP7中的服务器获取响应?
InitializeComponent();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com/");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
tbResponse.Text = reader.ReadToEnd();
// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();
Console.ReadLine();
此外,我使用这个扩展:click here,但我在Windows控制台应用程序上测试过,并没有任何问题,所以我认为问题在于我不了解WP7。
不要mak e同步请求;他们冻结了用户界面。 'GetResponse()'不存在的原因。 – SLaks
另请参见[检索结果时,WP7上的DownloadStringTaskAsync挂起](http://stackoverflow.com/questions/6448819/downloadstringtaskasync-on-wp7-hangs-when-retrieving-result) –