Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net Response.BinaryWrite无法在MAC中使用Safari_Asp.net_Macos_Safari_Response.write - Fatal编程技术网

Asp.net Response.BinaryWrite无法在MAC中使用Safari

Asp.net Response.BinaryWrite无法在MAC中使用Safari,asp.net,macos,safari,response.write,Asp.net,Macos,Safari,Response.write,我正在使用以下代码将PDF发送到浏览器 Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Length", fileBytes.Length.ToString()); Response.ContentType = "application/pdf"; Response.BinaryWrite(fileBytes)

我正在使用以下代码将PDF发送到浏览器

        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();
除了MAC中的Safari版本5.x之外,所有浏览器都能正常嵌入pdf。此外,它在MAC中的Firefox和Chrome上也能正常工作。 我想知道这是一个浏览器问题吗?或者Response.BinaryWrite有问题

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

[编辑]
此错误记录在Safari Developer Tools控制台中,无法加载资源:插件已处理加载,这似乎与PDF插件有关。

试试这个,它对我很好

        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();

PDF根本没有加载?有一个进度条吗?可能是进度条与安装的Adobe插件有关。@Ahmed:进度条完成后会发生什么?它是否在浏览器中打开pdf?@Razvan,它一直加载的问题似乎是使用Safari开发工具时出现的,加载资源失败时记录了一个错误:Plug-in handled load,那么如何找出它为什么不加载?加载资源失败:Plug-in handled load错误在加载页面时仍记录在控制台日志中。