Dear code master, I believe you all doing well.
I am writing an application where I uploaded a pdf file as varbinary(Max) this work file.
I want the user to view the pdf file first before downloading, when I run the application and click the button I get the pdf viewer inline but it display’s “Failed to load PDF document”.
My code is shown below:
- var DT = new DataTable();
- DT = ConnectAll.DownloadFile(TextBox1.Text.Trim());
- foreach (DataRow r in DT.Rows)
- {
- byte[] myFile = (byte[])r["docu"];
- Response.Clear();
- Response.Buffer = true;
- Response.ContentType = "application/pdf";
- Response.AddHeader("content-disposition", "inline;filename=MME.pdf");
- Response.Charset = "";
- Response.Cache.SetCacheability(HttpCacheability.NoCache);
- Response.BinaryWrite(myFile);
- Response.End();
- }
Can anybody help me ?
Thank you all


Manav PandyaRank #166 · 14.3K reputationPosted May 11, 2017, 8:11 PM EDT
Abraham OlatubosunRank #2,749 · 510 reputationPosted May 11, 2017, 9:53 PM EDT
Rahul PrasadRank #2,557 · 546 reputationPosted May 11, 2017, 5:27 PM EDT
Abraham OlatubosunRank #2,749 · 510 reputationPosted May 11, 2017, 7:17 PM EDT