Response.BinaryWrite没有MAC的Safari工作

问题描述:

我使用下面的代码的PDF发送到浏览器Response.BinaryWrite没有MAC的Safari工作

 Response.ClearContent(); 
     Response.ClearHeaders(); 
     Response.AddHeader("Content-Length", fileBytes.Length.ToString()); 
     Response.ContentType = "application/pdf"; 
     Response.BinaryWrite(fileBytes); 
     Response.Flush(); 
     System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest(); 

它运作良好(PDF正确嵌入在浏览器中)以外的Safari浏览器的所有(版本5.x)在MAC。此外,它适用于Mac和Firefox中的Firefox和Chrome。
我想知道它是一个浏览器问题?或者Response.BinaryWrite有问题?

[编辑]
Safari的行为,pdf根本没有加载。显示一个进度条并继续加载,可能与安装的PDF插件有关?那么,如何弄清楚为什么在Safari中这种行为呢?

[编辑]
这个错误被记录在Safari开发工具控制台“无法加载资源:插件所处理的负载”,这似乎是它涉及到PDF插件。

+0

在Safari中会发生什么? – ZippyV 2012-01-03 09:58:48

+0

PDF完全不加载?一个进度条在那里?可能是该progree栏与安装的Adobe插件有关。 – Ahmed 2012-01-03 10:01:02

+0

@ Ahmed:当进度条完成时会发生什么?它在浏览器中打开pdf吗? – 2012-01-03 10:19:46

试试这个,它的工作我没问题

 Response.ClearContent(); 
     Response.ClearHeaders(); 
     Response.ContentType = "application/pdf"; 
     Response.Buffer = true; 
     Response.AppendHeader("Accept-Header", attachmentObj.AttachmentFile.Length.ToString()); 
     Response.AppendHeader("content-disposition", "attachment; filename=\"" + HttpUtility.UrlEncode(attachmentObj.Description, System.Text.Encoding.UTF8) + "\""); 
     Response.AppendHeader("Pragma", "public"); 
     Response.BinaryWrite((byte[])attachmentObj.AttachmentFile.ToArray());   
     Response.Flush(); 
     Response.End(); 
+0

无法加载资源:加载页面时,插件处理的加载错误仍然记录在控制台日志中。 – Ahmed 2012-01-03 13:05:50