return binary content from within ASPX page

Discussion in 'ASP .Net' started by michal januszczyk, Jul 17, 2003.

  1. 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
    michal januszczyk, Jul 17, 2003
    #1
    1. Advertising

  2. 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);

    --
    I hope this helps,
    Steve C. Orr, MCSD
    http://Steve.Orr.net


    "michal januszczyk" <> wrote in message
    news:02b701c34c42$755b0e00$...
    > 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
    Steve C. Orr, MCSD, Jul 17, 2003
    #2
    1. Advertising

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

    Louis Dascoulias, AWS

    "Michal Januszczyk" <> wrote in message
    news:06d101c34c45$923afe60$...
    > >-----Original Message-----
    > >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);

    >
    > Thanx !
    > I still have another tiny problem I can't handle:
    > I would like the returned content to be opened in new
    > window. Is it somehow possible to specify this on aspx
    > page ?
    >
    Louis Dascoulias, Jul 17, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page