return binary content from within ASPX page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • michal januszczyk

    #1

    return binary content from within ASPX page

    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.Binary Write(binaryDat a);

    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

    #2
    Re: return binary content from within ASPX page

    You're missing a few vital lines of code:

    Response.Conten tType = "applicatio n/ms-word";
    Response.AddHea der("Content-Disposition", "inline;filenam e=test.doc");

    Response.Output Stream.Write(bi naryData);

    --
    I hope this helps,
    Steve C. Orr, MCSD



    "michal januszczyk" <michal_januszc zyk@hotmail.com > wrote in message
    news:02b701c34c 42$755b0e00$a00 1280a@phx.gbl.. .[color=blue]
    > 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.Binary Write(binaryDat a);
    >
    > 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[/color]


    Comment

    • Louis Dascoulias

      #3
      Re: return binary content from within ASPX page

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

      Louis Dascoulias, AWS

      "Michal Januszczyk" <michal_januszc zyk@hotmail.com > wrote in message
      news:06d101c34c 45$923afe60$a60 1280a@phx.gbl.. .[color=blue][color=green]
      > >-----Original Message-----
      > >You're missing a few vital lines of code:
      > >
      > >Response.Conte ntType = "applicatio n/ms-word";
      > >Response.AddHe ader("Content-
      > >Disposition" , "inline;filenam e=test.doc");
      > >Response.Outpu tStream.Write(b inaryData);[/color]
      >
      > 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 ?
      >[/color]


      Comment

      Working...