How to stream a PDF file as binary to the browser using .NET 2.0

I'm looking for a way to stream a PDF file from my server to the browser using .NET 2.0 (in binary).

I'm trying to grab an existing PDF file from a server path and push that up as binary to the browser.


这里你去:如何使用ASP.NET和Visual C#.NET编写二进制文件到浏览器


  • Set Content-Type : Response.ContentType = "application/pdf"
  • Set ContentDisposition , if you want to give a new name for the file: Response.Headers.Add("Content-Disposition", "attachment: filename=file.pdf");
  • Write the content, using Response.OutputStream as Mr. Kopp said.
  • Step 2 is not strictly necessary, but it's probably a good idea if you don't want the browser to try to save the PDF with the same name as your ASPX file.


    Write the binary to the output stream, Response.OutputStream . Then just add the header Content-Disposition header.

    链接地址: http://www.djcxy.com/p/6210.html

    上一篇: 把一个div放在锚内是否正确?

    下一篇: 如何使用.NET 2.0将PDF文件作为二进制流式传输到浏览器