Answer BinaryWrite does not work in Android browser

I have an array of bytes in the database, and I need to show this as a PDF file. Here is how I did it. However, this does not work on Android tablets (verified in 2.3.5 and 3.2).

Response.Clear();
Response.ContentType = "application/octet-stream";
Response.BufferOutput = true;
Response.Buffer = false;
Response.AddHeader("Content-Length", binaryData.Length.ToString());
Response.AppendHeader("Content-Disposition", "inline;filename=ClientDocument.PDF");
// Response.BinaryWrite(binaryData);
Response.OutputStream.Write(binaryData, 0, binaryData.Length);
Response.End();

Can you guys think about how I can make it work on all browsers?

Rate help

thank

+3
source share
2 answers

A couple of things ...

  • Change the content type to fix the mime type of PDF files. There are a huge number of them in the use of application / pdf, application / x-pdf, application / acrobat, applications / vnd.pdf, text / pdf, text / x-pdf ", we just use application / pdf.

    Response.ContentType = "application / pdf";

  • , , PDF , Content-Disposition.

  • ... ... , PDF , Content-Disposition "", "inline".

    Response.AppendHeader( "Content-Disposition", "attachment; filename = ClientDocument.PDF" );

+2

Android /?

, ( PDF, [] Android).

0

All Articles