关于HttpWebResponse.GetResponse()的问题
HttpWebRequestrequest;HttpWebResponseresponse;request=(HttpWebRequest)WebRequest.Crea...
HttpWebRequest request;
HttpWebResponse response;
request = (HttpWebRequest)WebRequest.Create(address);
request.Method = "POST";
result = GetString(doc);
buffer = Encoding.Default.GetBytes(result);
request.ContentLength = (long)buffer.Length;
using (Stream stream = request.GetRequestStream())
{
stream.Write(buffer, 0, buffer.Length);
}
response = (HttpWebResponse)request.GetResponse();//代码大家一看就懂,就是这句会出错。经常会抛出:The underlying connection was closed: An unexpected error occurred on a receive.的异常,翻译过来:基础连接已关闭:接收时发生意外错误。但是不是每次都发送失败,请问有人知道问题所在或者可能的原因吗? 展开
HttpWebResponse response;
request = (HttpWebRequest)WebRequest.Create(address);
request.Method = "POST";
result = GetString(doc);
buffer = Encoding.Default.GetBytes(result);
request.ContentLength = (long)buffer.Length;
using (Stream stream = request.GetRequestStream())
{
stream.Write(buffer, 0, buffer.Length);
}
response = (HttpWebResponse)request.GetResponse();//代码大家一看就懂,就是这句会出错。经常会抛出:The underlying connection was closed: An unexpected error occurred on a receive.的异常,翻译过来:基础连接已关闭:接收时发生意外错误。但是不是每次都发送失败,请问有人知道问题所在或者可能的原因吗? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询