code_junkie

How to set the name of the file when streaming a Pdf in a browser?

Nov 12th, 2011
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. System.IO.MemoryStream stream = new System.IO.MemoryStream();
  2.  
  3. stream = (System.IO.MemoryStream)this.Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
  4.  
  5. this.Response.Clear();
  6. this.Response.Buffer = true;
  7. this.Response.ContentType = "application/pdf";
  8. this.Response.BinaryWrite(stream.ToArray());
  9. this.Response.End();
  10.  
  11. Content-Disposition: inline; filename=foo.pdf
  12.  
  13. System.IO.MemoryStream stream = new System.IO.MemoryStream();
  14.  
  15. stream = (System.IO.MemoryStream)this.Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
  16.  
  17. this.Response.Clear();
  18. this.Response.Buffer = true;
  19. this.Response.ContentType = "application/pdf";
  20. this.Response.AddHeader("Content-Disposition", "attachment; filename=""+FILENAME+""");
  21. this.Response.BinaryWrite(stream.ToArray());
  22. this.Response.End();
Add Comment
Please, Sign In to add comment