Trying to stream a PDF file with asp.net is producing a “damaged file”

后端 未结 6 409
长情又很酷
长情又很酷 2020-12-16 23:51

In one of my asp.net web applications I need to hide the location of a pdf file being served to the users.

Thus, I am writing a method that retrieves its binary con

6条回答
  •  执念已碎
    2020-12-17 00:15

    I've got something similar working on a current 2.0 web site. And I remember struggling to get it to work though it's been a while so I don't remember the struggles.

    There are, though, a few differences between what I have what you have. Hopefully these will help you solve the problem.

    • After the ClearContent call, I call ClearHeaders();
    • I'm not specifying a length.
    • I'm not specifing inline on the Disposition
    • I know everyone says not to do it, but I have a Response.Flush(); followed by Response.Close();

    And, one other thing, check your contentType value to make sure it is correct for PDFs (("Application/pdf").

提交回复
热议问题