Streaming data to the browser as a file of unknown size

Posted by Sir Psycho on Stack Overflow See other posts from Stack Overflow or by Sir Psycho
Published on 2010-03-31T06:50:58Z Indexed on 2010/03/31 6:53 UTC
Read the original article Hit count: 208

Filed under:
|

I have some data which is queried from the database and I'd like to send it to the client as a csv file.

The file size varies each time due to the fact that the DB data returned can be of any size.

Instead of saving this file to the hard disk, I'd like to send it to the browser at the same time it's being processed into a CSV by my algorithm.

Response.Write seems useless. For some reason, the file download dialog is only displayed once my processing is finished. This seems odd as I'm writting all my output to the Response.Output stream.

I have downloaded files on the web before where the filesize is not known and the browser just keeps on downloading. Is there any way to achieve this?

The following stackoverflow thread did not offer any good advise. http://stackoverflow.com/questions/873995/asp-net-downloading-large-files-of-unknown-size

Thanks

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about streaming