总是冻结在httpwebresponse并且无法做任何事情

时间:2014-02-11 05:21:08

标签: c# android httpwebresponse

HttpWebRequest webRequest = WebRequest.Create("http://127.0.0.1/login.php?id=boonjye91") as HttpWebRequest;

HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse;
response.Close();
// Read the response
StreamReader reader = new StreamReader(response.GetResponseStream());
var responseText = reader.ReadToEnd();

// This just shows the server's response, but you'll probably want to do other things
Toast.MakeText(this, responseText, ToastLength.Long).Show();

当我运行断点时。我探究到它被卡住了冻结web响应。 为什么?

1 个答案:

答案 0 :(得分:0)

尝试在Asyntask中运行并在onPostExecute()方法中获得所需的结果。

http://developer.android.com/reference/android/os/AsyncTask.html