标签:htm try exception reader ade ons exce pre 错误信息
HttpWebRequest 请求时,服务器会返回500 501这些错误 并包含错误信息,通过如下代码可以拿到错误信息
HttpWebResponse res;
try
{
res = (HttpWebResponse)req.GetResponse();
}
catch (WebException ex)
{
res = (HttpWebResponse)ex.Response;
}
StreamReader sr = new StreamReader(res.GetResponseStream(), strEncode);
strHtml = sr.ReadToEnd();
HttpWebRequest 在出错时获取response内容
标签:htm try exception reader ade ons exce pre 错误信息
原文地址:http://www.cnblogs.com/bfyx/p/7966239.html