byte[] arrayofbyte = new System.Net.WebClient().DownloadData("http://pdfurl");
MemoryStream ms = new MemoryStream(arrayofbyte);
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
System.Web.HttpContext.Current.Response.AddHeader("ContentType", "application/pdf; charset=utf-8");
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + DateTime.Now.Ticks.ToString() + ".pdf" + ";");
System.Web.HttpContext.Current.Response.BinaryWrite(ms.ToArray());
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();
Asked
Active
Viewed 484 times
-2

Soner Gönül
- 97,193
- 102
- 206
- 364

Shailesh
- 554
- 1
- 6
- 29
-
2Only code questions are not welcome usually. How about adding some explanation about your problem? – Soner Gönül Jun 02 '15 at 07:55
-
You are downloading the file yourself, then forward it? Are you sure the pdfurl leads to a valid file, and that `ms` has content? – Alexander Jun 02 '15 at 08:29
1 Answers
0
I think you may be missing the content length header.
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", ms.Length.ToString());

Plebsori
- 1,075
- 9
- 23