基础连接已关闭
代码如下,泛红部分老报“基础连接已关闭:接受时发生错误”,谁能帮我看看
string returnValue = "";
byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(strXML);
WebRequest webrequest = WebRequest.Create(postUrl);
webrequest.Method = "POST";
webrequest.Timeout = 60 * 1000;
webrequest.ContentType = "application/x-www-form-urlencoded";
webrequest.ContentLength = bytes.Length;
Stream oStreamOut = webrequest.GetRequestStream();
oStreamOut.Write(bytes, 0, bytes.Length);
oStreamOut.Close();
WebResponse myWebResponse = webrequest.GetResponse(); Stream streamResponse = myWebResponse.GetResponseStream();
Encoding encode = Encoding.GetEncoding("GB2312");
StreamReader streamRead = new StreamReader(streamResponse, encode);
Char[] readBuff = new Char[256];
int count = streamRead.Read(readBuff, 0, 256);
while (count > 0)
{
String outputData = new String(readBuff,0,count);
returnValue += outputData;
count = streamRead.Read(readBuff, 0, 256);
}
streamResponse.Close();
streamRead.Close();
myWebResponse.Close();
return returnValue;