H
hoenes1
Hi all,
I'm trying to send files to a client following the instructions of
http://support.microsoft.com/?id=812406
Everything works fine, but if files are large and/or if the bandwidth
is small, after a certain time, the error "The connection with the
server was reset" occurs. I think the time span when this error occurs
relates closely to the IIS HTTP Connection timeout setting which is by
default set to 120 seconds (changing the value to 30 seconds results
in the error occuring much earlier). Is my only chance to increase
this value to about 10.000 to enable a user to download a large file
with small bandwidth or am I barking up the wrong tree? Maybe it is
possible to renew the http connection in every pass of the while-loop?
Here's a code sample which sends the file:
long bufSize = 65536;
while (offset < size && Response.IsClientConnected)
{
if (size-offset < bufSize)
{
bufSize = size-offset;
buf = new byte[bufSize];
}
fs.Read(buf, 0, (int)bufSize);
if (Response.IsClientConnected)
{
Response.OutputStream.Write(buf, 0, (int)bufSize);
Response.Flush();
}
else
break;
offset += bufSize;
}
Please post if you know something about this issue, I'm sure many
others will benefit from a solution since downloading large files is a
very common task.
Thanks in advance.
I'm trying to send files to a client following the instructions of
http://support.microsoft.com/?id=812406
Everything works fine, but if files are large and/or if the bandwidth
is small, after a certain time, the error "The connection with the
server was reset" occurs. I think the time span when this error occurs
relates closely to the IIS HTTP Connection timeout setting which is by
default set to 120 seconds (changing the value to 30 seconds results
in the error occuring much earlier). Is my only chance to increase
this value to about 10.000 to enable a user to download a large file
with small bandwidth or am I barking up the wrong tree? Maybe it is
possible to renew the http connection in every pass of the while-loop?
Here's a code sample which sends the file:
long bufSize = 65536;
while (offset < size && Response.IsClientConnected)
{
if (size-offset < bufSize)
{
bufSize = size-offset;
buf = new byte[bufSize];
}
fs.Read(buf, 0, (int)bufSize);
if (Response.IsClientConnected)
{
Response.OutputStream.Write(buf, 0, (int)bufSize);
Response.Flush();
}
else
break;
offset += bufSize;
}
Please post if you know something about this issue, I'm sure many
others will benefit from a solution since downloading large files is a
very common task.
Thanks in advance.