我的解决办法:用下面红色的行,替换掉注释行,不设置ContentLength
代码片断:
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(BaseUrl);
httpReq.Method = "POST"; //对发送的数据不使用缓存
httpReq.AllowWriteStreamBuffering = false; //设置获得响应的超时时间(300秒)
httpReq.Timeout = 300000;
httpReq.ContentType = "multipart/form-data; boundary=" + strBoundary;
long length = fs.Length + postHeaderBytes.Length + boundaryBytes.Length;
long fileLength = fs.Length;
httpReq.SendChunked = true;
//httpReq.ContentLength = length;