Write PDF stream to response stream

后端 未结 2 682
你的背包
你的背包 2021-01-06 16:52

I am having problems when I tried to run the following code from my asp.net page. The code is from another post (http://stackoverflow.com/questions/5828315/write-pdf-strea

相关标签:
2条回答
  • 2021-01-06 17:10

    Consider using HttpResponse.TransmitFile (ASP.NET >= 2.0), especially for large files because it writes the file without buffering it into server memory.

    Also, make sure you always set the Response.ContentType property to the appropriate MIME type or browsers will sometimes have trouble with downloading your files correctly, especially if you are writing the file from a handler:

    Response.ContentType = "application/pdf";
    
    0 讨论(0)
  • 2021-01-06 17:16

    You can use Response.WriteFile instead of all the buffer work.

    protected void Page_Load(object sender, EventArgs e) 
    {         
        Context.Response.WriteFile(@"C:\Downloads\Test.pdf"); 
    }
    
    0 讨论(0)
提交回复
热议问题