Serving a Binay Download file from a Stream (ASP.NET)

  • Thread starter Thread starter Steve C. Orr [MVP, MCSD]
  • Start date Start date
How would you go about serving a binary file for download from an ASP.NET
page starting with a Stream?

I would like to be able to do this using a dynamically generated stream
rather than the clucky approach of saving the file to the file-system, and
then linking to it. This is horrible as I've then got to clean up after
somehow.

Is this something like setting the Response.ContentType to "?? BINARY ???"
and writing the stream to the Response.OutputStream? If so what is the HTTP
MIME value supposed to be.

Any guidance would be appreciated!
Thanks....
===
Phil
(Auckland | Aotearoa)
 
Thanks for Steve's informative tech ariticles.

Hi Phil,

To serving a binary download from a stream is quite similar with from a
existing file. You can make use fo the
Response.Write method or the Response.OutputStream.
1) Retrieve the byte array from the certai Stream you have and use
Response.Write to write in to outputstream.

2) Make write operation directly on the Response.Outputstream.

In addtion, here is another KB article which I think may also be helpful to
you:

#HOW TO: Read and Write BLOB Data by Using ADO.NET Through ASP.NET
http://support.microsoft.com/?id=326502

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Back
Top