【发布时间】:2012-08-28 11:10:24
【问题描述】:
我有一个简单的 HTTP 处理程序,它允许我们的用户检索远程存储的 PDF 文件。 令人惊讶的是,当从 IE9 调用处理程序但 IE8 卡住时,此代码运行良好。您必须再次调用 url 才能正确显示 pdf。
我在网上查了一下,看看是否还有其他与回复有关的事情。我最初以为响应没有正确结束,但发现以下文章: http://blogs.msdn.com/b/aspnetue/archive/2010/05/25/response-end-response-close-and-how-customer-feedback-helps-us-improve-msdn-documentation.aspx 显然,不应使用 context.Response.Close() 或 context.Response.End()。
我正在使用的代码:
using System.Web;
namespace WebFront.Documents
{
public class PDFDownloader : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// Makes sure the page does not get cached
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
// Retrieves the PDF
byte[] PDFContent = BL.PDFGenerator.GetPDF(context.Request.QueryString["DocNumber"]);
// Send it back to the client
context.Response.ContentType = "application/pdf";
context.Response.BinaryWrite(PDFContent);
context.Response.Flush();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
有人遇到过同样的问题吗?
【问题讨论】:
标签: c# asp.net internet-explorer-8 internet-explorer-9 httphandler