我用C#2003 使用
private void button1_Click(object sender, System.EventArgs e)
{
string url=@"
http://192.168.1.1/login.php?username=001&password=001";
// Creates an HttpWebRequest with the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url );
// Sends the HttpWebRequest and waits for the response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
// Gets the stream associated with the response.
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( receiveStream, encode );
this.label1.Text=readStream.ReadToEnd();
// Releases the resources of the Stream.
readStream.Close();
// Releases the resources of the response.
myHttpWebResponse.Close();
}
在模拟器运行老是出现错误提示:
未处理的托管异常
一个托管的IOException 发生在 Appliacation ::Run+0x1a
块区长度无效
能不能帮忙看看是怎么回事?谢谢