Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.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
C# 在IE6中查看PDF_C#_Asp.net_Pdf - Fatal编程技术网

C# 在IE6中查看PDF

C# 在IE6中查看PDF,c#,asp.net,pdf,C#,Asp.net,Pdf,我正在尝试打开一个PDF文档以在IE6中显示。我正在使用以下代码段: response.ContentType = healthMedia.MediaKey.MimeType; response.ClearHeaders(); response.AddHeader("Content-Disposition", "inline; filename=" + mediaKeyId); int contentLength = healthMedia.Content.Length; resp

我正在尝试打开一个PDF文档以在IE6中显示。我正在使用以下代码段:

response.ContentType = healthMedia.MediaKey.MimeType;
response.ClearHeaders();     

response.AddHeader("Content-Disposition", "inline; filename=" + mediaKeyId);

int contentLength = healthMedia.Content.Length;
response.AppendHeader("content-length", Convert.ToString(contentLength));
response.OutputStream.Write(healthMedia.Content, 0, contentLength);
healthMedia.MediaKey.MimeType;等于“应用程序/pdf”

这将打开“保存”对话框。如果我注释掉Response.ClearHeaders;我得到一个新窗口弹出,但它的内容是一堆jibberish随机编码文本

如何让IE6正确打开PDF


-尼克:你试过Response.End和Response.Buffer=true吗?您可能还需要设置缓存策略。

如果有帮助,请使用response.BinaryWrite而不是response.OutputStream.Write

看起来您做得不错。您是否尝试过从IE6中的其他网站打开PDF?可能是IE6浏览器的Adobe Reader插件配置不正确。哈哈!我想当我看到浏览器试图下载PDF时,我应该想到这一点。感谢…对于“正确”的值X;-AdobeReader插件是目前所有软件中最大比例的web攻击。允许PDF阅读器作为面向网络的插件运行是鲁莽的。这来自内存,我更喜欢提供PDF作为附件,以避免使用糟糕的Acrobat reader插件冻结浏览器。谢谢Chris。。清除标题后,浏览器试图下载pdf。插件丢失了。我当前正在添加此标头响应。AppendHeadercontent-length,Convert.ToString内容长度;这就是你的建议吗?在IE6中,也需要结束响应并使其缓冲。我认为BinaryWrite做的正是他已经在做的事情,而且他无论如何都需要长度