HTTP传输调试(输出详细)
HttpWebResponse res = null;
WebResponse response = null;
try
{
WebResponse response = webRequest.GetResponse();
}
catch (WebException ex1)
{
res = (HttpWebResponse)ex1.Response;
}
finally
{
StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
string strhtml = sr.ReadToEnd();
HttpContext.Current.Response.Write(strhtml);
}
8.-
GetResponse() 基础连接已经关闭:服务器关闭了本应保持活动状态的连接
(1.原因:
(1)KeepAlive默认为true,与internet保持持续连接 ,服务器关闭了连接,使用HttpWebResponse.GetResponse()出错
(2)HttpWebRequest 超过了最大连接数
(3)网络响应慢而导致超时
都无效,最后搜到一个添加http协议,如下
request.ProtocolVersion = HttpVersion.Version10;
成功通过。特记录下。