要asp.net(c#)代码
------解决方案--------------------------------------------------------
private string GetWebContent(string Url)
{
string strResult = " ";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
//声明一个HttpWebRequest请求
request.Timeout = 30000;
//设置连接超时时间
request.Headers.Set( "Pragma ", "no-cache ");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//返回响应
Stream streamReceive = response.GetResponseStream();
//获取服务器的文件流
Encoding encoding = Encoding.GetEncoding( "GB2312 ");
StreamReader streamReader = new StreamReader(streamReceive, encoding);
strResult = streamReader.ReadToEnd();
}
catch(Exception e)
{
Response.Write(e.Message);
}
return strResult;
}
------解决方案--------------------------------------------------------
只要在web.config里面的 <customerror> 加上errorcode 就可以自动判别出来了阿