return binary content from within ASPX page

M

michal januszczyk

my aspx page gets binary data with ms-word file. (just
byte[] array). I want this data to send back to the
browser, but when i try to do this with the following
method:
byte[] binaryData =....
Response.BinaryWrite(binaryData);

the binary data is appended with some html header .
Obviously winword does not recognize the file format.

The question is:
How to reply the browser in a way, that it would
recognize the file format and open the file ?

Thanx for any suggestions
Michal Januszczyk
 
S

Steve C. Orr, MCSD

You're missing a few vital lines of code:

Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition", "inline;filename=test.doc");

Response.OutputStream.Write(binaryData);
 
L

Louis Dascoulias

Michal,
In a javascript function: window.open(.....).. Look it up to see the params.

Louis Dascoulias, AWS
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top