PDF coming as text on browser

Posted by spt3210 on Stack Overflow See other posts from Stack Overflow or by spt3210
Published on 2010-06-01T14:28:52Z Indexed on 2010/06/01 14:33 UTC
Read the original article Hit count: 210

Filed under:
|
|

I am trying to display a PDF from database (byte[]) to user.

I am using code below to render PDF. It is giving me PDF as binary text as shown below. Instead of open in PDF application it is rendering PDF as text.

Response.Buffer = true;
        Response.Charset = "";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        //Response.AddHeader("Content-Length", fileToDownload.Length.ToString());
        //Response.AddHeader("Content-Disposition", "inline; name=RemoteUserGuide.pdf");
        Response.AppendHeader("content-length", fileToDownload.Length.ToString());
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(fileToDownload);
        Response.Flush();
        ////Response.Close();
        Response.End();

Any Ideas? alt text

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET