111,126
社区成员
发帖
与我相关
我的任务
分享
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://192.168.0.200/index2.html");
try
{
HttpWebResponse respon = (HttpWebResponse)myReq.GetResponse();
}
catch (WebException ex)
{
HttpWebResponse res = (HttpWebResponse)ex.Response;
Stream rs = res.GetResponseStream();
Encoding encode = Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(rs, encode);
string tmp = readStream.ReadToEnd();
res.Close();
readStream.Close();
MessageBox.Show(tmp);
}
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /index2.html was not found on this server.</p>
</body></html>