ASP.Net ways of streaming pdf / word docs?

J

Jeff T

Hi everyone,

We've have files we'd like to store in a SQL Server blob or text column and
make available online for our clients. Instead of linking to a document
sitting on a file server, we figure it'll be easier to manage the document
store this way.

Could someone point me to a tutorial or online docs on what classes .Net
provides for streaming bytes (I assume that's what I'll be doing) from a
database to a web browser and vice versa? Document upload will be the next
step in the process.

I'm guessing part of this will involve setting the http response headers.
The best thing would be a pre-existing tutorial but any help is appreciated.
Thanks!

Sounds like all you need to do is grab the binary data from the
database based on some sort of input and then send it to the browser.
You have the option to have the browser prompt the user to open/save
or just to have the browser open the document if it can within it's
window. (for example, IE can display Word docs).

So here is some sample C# code to send a file to the browser and have
it prompt the user to open/save it.

Response.ContentType = "application/excel";
Response.AddHeader("Content-Disposition", "attachment;
filename=" + nameFromTheDB);
Response.BinaryWrite(binaryDataFromTheDB);
Response.End();
 
J

Jim Bancroft

Hi everyone,

We've have files we'd like to store in a SQL Server blob or text column and
make available online for our clients. Instead of linking to a document
sitting on a file server, we figure it'll be easier to manage the document
store this way.

Could someone point me to a tutorial or online docs on what classes .Net
provides for streaming bytes (I assume that's what I'll be doing) from a
database to a web browser and vice versa? Document upload will be the next
step in the process.

I'm guessing part of this will involve setting the http response headers.
The best thing would be a pre-existing tutorial but any help is appreciated.
Thanks!
 
G

Guest

Steve,
Can you provide your excellent article in EasyUploads in C# too?
Thank you.
--
Pen


Steve C. Orr [MCSD said:
Yes, this article explains how to upload binary files into your SQL Server
database and how to stream them back out again. And yes it does cover byte
streaming.

http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net


Jim Bancroft said:
Hi everyone,

We've have files we'd like to store in a SQL Server blob or text column
and make available online for our clients. Instead of linking to a
document sitting on a file server, we figure it'll be easier to manage the
document store this way.

Could someone point me to a tutorial or online docs on what classes .Net
provides for streaming bytes (I assume that's what I'll be doing) from a
database to a web browser and vice versa? Document upload will be the
next step in the process.

I'm guessing part of this will involve setting the http response headers.
The best thing would be a pre-existing tutorial but any help is
appreciated. Thanks!
 

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

Forum statistics

Threads
473,808
Messages
2,569,686
Members
45,452
Latest member
AmberLayde

Latest Threads

Top