return binary content from within ASPX page

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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.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 Guest

  2. Similar Questions and Discussions

    1. What is the fastest way to return the binary of a file?
      Currently this is what I'm doing and it takes about 30 - 60 seconds for 88 kb file to show in my web browser from my web service. I think that is...
    2. How can I return a binary file (image) from a web service
      A url to an image file will be passed to my web service. What function can I use that will get the image and return the image in binary form? ...
    3. Accessing a aspx page using HttpWebRequest from another aspx page on the same webapp
      Did you have any luck on this as I have the same problem. Maybe you can help me out of you solved your problem.
    4. encrypt .aspx file content
      Hi there Is it possible, as an added (fairly paranoid) security measure, to encrypt the content of, say, an .aspx file on the server? Best...
    5. Return Codes From MessageBox in .ASPX ?
      Greetings. I've created a simple ASPX form that displays a record from a SQL Server table. I have a "Delete" button on the form. When the user...
  3. #2

    Default Re: return binary content from within ASPX page

    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
    [url]http://Steve.Orr.net[/url]


    "michal januszczyk" <michal_januszczyk@hotmail.com> wrote in message
    news:02b701c34c42$755b0e00$a001280a@phx.gbl...
    > 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 Guest

  4. #3

    Default 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_januszczyk@hotmail.com> wrote in message
    news:06d101c34c45$923afe60$a601280a@phx.gbl...
    > >-----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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139