unable to read data from the transport
Hi
I am getting this exception "unable to read data from the transport connection the connection was closed"
i ref this blog http://briancaos.wordpress.com/2012/07/06/unable-to-read-data-from-the-transport-connection-the-connection-was-closed/
but no use of that. Can some help me in this.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Concat(ServiceURL, "download/LargeFile"));
request.Method = METHOD_TYPE;
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.ServicePoint.ConnectionLimit = 1;
FileDTO file = new FileDTO();
file.tokenkey = obj.tokenkey;
file.logonkey = obj.logonkey;
file.fileid = product.fileid;
string path = @"C:\Try\FileDownloads\" + product.LastUpdatedDate; //C:\Try\FileDownloads\201-09-04
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
streamWriter.Write(string.Concat("obj=", new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(file)));
try
{
var response = request.GetResponse();
using (Stream stream = response.GetResponseStream())
{
using (MemoryStream memoryStream = new MemoryStream())
{
// Stream the response to a MemoryStream via the byte array buffer
Byte[] buffer = new Byte[0x1000];
Int32 bytesRead;
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
memoryStream.Write(buffer, 0, bytesRead);
}
using (FileStream fs = new FileStream(path + "\\" +product.filename, FileMode.CreateNew, FileAccess.Write))
{
fs.Write(memoryStream.ToArray(), 0, memoryStream.ToArray().Count());
}
}
}
obj.tokenkey = response.Headers.Get("User-Tokenkey");
obj.logonkey = response.Headers.Get("User-Logonkey");
}
catch
{
}
I am able max 103 MB, but my file size is more than 2GB