我一直试图让这个 aspx 页面提供一个 pdf。它在 Firefox 中正常工作,但 IE 提供
Internet Explorer 无法从 SERVER_NAME 下载 getform.aspx
Internet Explorer 无法打开此 Internet 站点。请求的站点不可用或找不到。
这是我的代码的一般功能。它分布在多个函数中(这就是我们不使用 WriteFile 的原因 - 有时我们会即时生成 pdf),但通常是这样的:
FileStream fs = File.Open(Path.Combine(PdfBasePath, "form.pdf"), FileMode.Open, FileAccess.Read);
Stream output = Response.OutputStream;
byte[] buffer = new byte[BUFFER_SIZE];
int read_count = fs.Read(buffer, 0, BUFFER_SIZE);
while (read_count > 0)
{
output.Write(buffer, 0, read_count);
read_count = fs.Read(buffer, 0, BUFFER_SIZE);
}
fs.Close();
Response.Clear();
Response.ContentType = System.Net.Mime.MediaTypeNames.Application.Pdf;
Response.AddHeader("Content-Disposition", "attachment; filename=form.pdf");
Response.Output.Flush();
Response.End();
查看 Fiddler,正在使用以下方法获取页面:
GET /getform.aspx?Failure=Y&r=someencryptedstring HTTP/1.1
它因此被返回到浏览器:
HTTP/1.1 200 OK
日期:2009 年 4 月 9 日星期四 22:08:33 GMT
服务器:Microsoft-IIS/6.0
X-Powered-By:ASP.NET
X-AspNet-Version:2.0.50727
Pragma:no-cache
Content-处置:附件;filename=form.pdf
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: -1
Content-Type: application/pdf
Content-Length: 628548
这真的让我很烦。我没有使用 SSL,否则这篇知识库文章似乎适用。有人有想法么?