[SOLVED] PDF download from aspx page


I have a page that when a user clicks a button, a PDF is dynamically generated and offered for them to download.

This is the code that’s letting the user download the pdf:

// Omitted code that generates the pdf bytes

response.ContentType = "application/octetstream";
response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);

On my machine and many others using a mixture of Chrome, IE 7/8/9b and Firefox, this is working as expected; the user clicks the button, the PDF gets downloaded.

On some instances of IE7, our users are reporting that they are getting an error message:

“Internet Explorer cannot download Publish.aspx from thesite.com

Internet Explorer was not able to open this Internet site. The requested site is either not available or cannot be found. Please try again later”.

Publish.aspx is the page that the button is residing on, so that page is available. IE should be downloading the pdf.

Is there anything that is wrong with the above code that could be causing this on certain machines? Or is it down to particular security / OS / browser settings?


These are the response headers from fiddler:

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Content-Type: application/octetstream
Expires: -1
Server: Microsoft-IIS/7.5
Content-Disposition: attachment; filename=myPdf.pdf
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Fri, 12 Nov 2010 09:48:06 GMT
Content-Length: 45772


Very recently I bumped into the same error. In my case I was using https and no caching. It seems to be a security feature in IE to not download the file. From EricLaw’s IEInternals:

if a user tries to download* a file over a HTTPS connection, any response headers that prevent caching will cause the file download process to fail.


Answered By – Joop

Answer Checked By – Mildred Charles (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *