我有一個頁面,當用戶點擊一個按鈕時,PDF就會動態生成並提供給他們下載。從aspx頁面下載PDF
此處所說的讓用戶下載PDF的代碼:
// Omitted code that generates the pdf bytes
response.ContentType = "application/octetstream";
response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
response.BinaryWrite(pdfBytes);
response.End();
在我的機器和其他許多人使用Chrome的混合物,IE 7/8/9B和Firefox,這是按預期工作;用戶點擊按鈕,PDF文件被下載。
在IE7的某些情況下,我們的用戶也報告說,他們所得到的錯誤消息:
「Internet Explorer無法從thesite.com下載Publish.aspx
的Internet Explorer無法打開此互聯網站點,請求的站點不可用或無法找到,請稍後再試。「
Publish.aspx是該按鈕所在的頁面,所以頁面是可用。 IE應該下載pdf。
上面的代碼有什麼問題可能導致某些機器出現這種情況?或者是否是特定的安全/操作系統/瀏覽器設置?
編輯:
這些是小提琴手響應頭:
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
這將是很高興看到所有響應標題。 – 2010-11-12 09:41:50
編輯以包含響應標題 – DavidGouge 2010-11-12 09:49:52