Determine whether download was cancelled

H

hoenes1

How can I determine whether a download has been cancelled by the
client? I'm sending the file from an aspx page in chunks of 4K. When
the user presses "Cancel" in his download dialog, the next call of
Response.Flush() hangs and resets my Session Object after about a
minute. The Response.IsClientConnected property is still true after
the user pressed "Cancel". Is there a workaround for this problem?
The Code is:

// fs --> FileStream
// buffer --> byte[]

while (offset < filesize)
{
length = filesize;
if (length > blocksize)
length = blocksize;
fs.Read(buffer, 0, (int)length);
Response.BinaryWrite(buffer);
if (Response.IsClientConnected)
Response.Flush(); // here it hangs after the user cancelling
else
break;
offset += length;
}

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top