我有一个简单的HTTP处理程序,它允许我们的用户检索远程存储的PDF文件。 令人惊讶的是,当处理程序从IE9调用但IE8仍然卡住时,此代码运行良好。您必须再次调用该URL才能正确显示PDF。context.Response.Flush()不能在IE8上工作,但在IE9上正常工作
我在网上查了一下,看看是否有什么进一步处理响应。我最初以为的反应是不正确结束,却发现下面的文章: 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;
}
}
}
}
这儿还有没有人面临着同样类型的问题?
[IE 8和客户端缓存](http://stackoverflow.com/questions/8348214/ie-8-and-client-side-caching)的可能重复也见http://stackoverflow.com/问题/ 9185678/ie7-8-pdf-file-wont-download-with-http-get – nemesv