John
John

Reputation: 2792

ASP.NET - Securely Display PDF Without Caching

I'm looking for a way to display a PDF in the web browser securely. Something other than downloading the file, which would be stored in temporary internet files.

I was thinking of something like this:

http://www.codeproject.com/Articles/41933/ASP-NET-PDF-Viewer-User-Control-Without-Acrobat-Re

But images would be cached. I want to be able to set no-cache and no-store headers on the PDF's data.

The idea I came up with so far would be to read a page out of the PDF into an image and deliver the image as base 64 embedded the HTML of the page (which would have the appropriate response headers). I anticipate that this would be a very slow way of doing things, though.

Is there a better solution, maybe even a nice ASP.NET control for this?

Thanks!

Upvotes: 1

Views: 922

Answers (1)

Joe
Joe

Reputation: 1669

Add the following to your .htaccess file

Code:

<FilesMatch "\.pdf$">
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"

</FilesMatch>

This should turn off all caching.

Upvotes: 1

Related Questions