重定向到PDF文件时出错 [英] Error When Redirecting to a PDF file

查看:80
本文介绍了重定向到PDF文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我们最近将我们的网络服务器从Win2K移到了Win2003。应用程序

工作正常。唯一的问题是当用户以PDF格式查看报告时,IE

不会显示它。以下代码用于重定向:


Response.Redirect(" /website/pdffiles/myreport.pdf");

Response.End;


IE打开文件下载框,如果您点击打开按钮按钮然后

没有任何反应。如果您点击保存按钮按钮出现以下错误

出现:


Internet Explorer无法下载myreport.pdf来自网站。

Internet Explorer无法打开此Internet站点。

请求的网站要么不可用,要么找不到。请稍后再试一次

。如果我使用以下代码,请使用$



<%

pdfFile =" myreport.pdf";

Response.Clear;

Response.ContentType =" application / pdf";

Response.AddHeader(" Content-Type"," application / pdf");

Response.AddHeader(" content-disposition"," inline; filename =" +

pdfFile);

Response.BinaryWrite(" / website / pdffiles /" + pdfFile);

Response.End;

%>


Acrobat打开并显示以下错误文件未开始

with''%PDF - ''" 。


非常感谢任何帮助。

Hi,

We recently moved our webserver from Win2K to Win2003. The application
works fine. Only problem is that when user views a report as a PDF, IE
does not show it. The following code is used to redirect:

Response.Redirect("/website/pdffiles/myreport.pdf");
Response.End;

IE opens a "File Download" box and if you click the "open" button then
nothing happens. If you click the "Save" button the following error
comes up:

"Internet Explorer cannot download "myreport.pdf" from "website".
Internet Explorer was not able to open this Internet site. The
requested site is either unavialable or cannot be found. Please try
again later."

if I use the following code:
<%
pdfFile = "myreport.pdf";
Response.Clear;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("content-disposition", "inline;filename=" +
pdfFile);
Response.BinaryWrite("/website/pdffiles/" + pdfFile);
Response.End;
%>

Acrobat open and displays the following error "File does not begin
with ''%PDF-''".

Any help would be greatly appreciated.

推荐答案

ma ******* @ yahoo.com 写于2007年6月6日星期三16:10:48 -0700:
ma*******@yahoo.com wrote on Wed, 06 Jun 2007 16:10:48 -0700:




我们最近莫从Win2K到Win2003我们的网络服务器。应用程序

工作正常。唯一的问题是当用户以PDF格式查看报告时,IE

不会显示它。以下代码用于重定向:


Response.Redirect(" /website/pdffiles/myreport.pdf");

Response.End;


IE打开文件下载框,如果您点击打开按钮按钮然后

没有任何反应。如果您点击保存按钮按钮出现以下错误

出现:


Internet Explorer无法下载myreport.pdf来自网站。

Internet Explorer无法打开此Internet站点。

请求的网站要么不可用,要么找不到。请稍后再试一次


Hi,

We recently moved our webserver from Win2K to Win2003. The application
works fine. Only problem is that when user views a report as a PDF, IE
does not show it. The following code is used to redirect:

Response.Redirect("/website/pdffiles/myreport.pdf");
Response.End;

IE opens a "File Download" box and if you click the "open" button then
nothing happens. If you click the "Save" button the following error
comes up:

"Internet Explorer cannot download "myreport.pdf" from "website".
Internet Explorer was not able to open this Internet site. The
requested site is either unavialable or cannot be found. Please try
again later."



你可以在IE中关闭显示友好的错误消息然后再试一次吗?地址URL在IE中显示的是什么?


您是否将PDF添加到IIS允许的MIME类型列表中?开箱即用

IIS6允许的很少,它是一个更安全的型号,您需要启用任何您想要下载的

文件扩展名。

Can you turn off show friendly error messages in IE and try again? What does
the address URL show in IE?

Did you add PDF to the list of allowed MIME types to IIS? Out of the box
IIS6 allows very little, it''s a more secure model and you need to enable any
file extensions that you want to allow to be downloaded.


如果我使用以下代码:

<%

pdfFile =" myreport.pdf" ;;

Response.Clear;

Response.ContentType =" application / pdf" ;;

Response.AddHeader(" Content-Type", " application / pdf");

Response.AddHeader(" content-disposition"," inline; filename =" +

pdfFile);

Response.BinaryWrite(" / website / pdffiles /" + pdfFile);

Response.End;

%>


Acrobat打开并显示以下错误文件未开始

with''%PDF - ''"。
if I use the following code:
<%
pdfFile = "myreport.pdf";
Response.Clear;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("content-disposition", "inline;filename=" +
pdfFile);
Response.BinaryWrite("/website/pdffiles/" + pdfFile);
Response.End;
%>

Acrobat open and displays the following error "File does not begin
with ''%PDF-''".



BinaryWrite发送原始二进制数据。在这种情况下,您将发送字符串

/website/pdffiles/myreport.pdf作为数据。要使用BinaryWrite在文件中发送

数据,您需要打开文件,读取它的内容,然后

将其传递给BinaryWrite。如果你整理重定向就可以了。

不需要这样做。


Dan

BinaryWrite sends raw binary data. In this case, you are sending the string
/website/pdffiles/myreport.pdf as the data. To use BinaryWrite to send the
data in the file, you need to open the file, read it''s content, and then
pass that into BinaryWrite. If you sort out the redirection to work you
won''t need to do this.

Dan

嗨Dan,


我将PDF MIME添加到服务器。它没有任何区别。当我点击打开或保存按钮时,我仍然会得到相同的错误



窗口中的URL是重定向到PDF文件的原始ASP页面。不显示PDF

文件(/webserver/pdffiles/myreport.pdf)URL。


哦,我错误地遗漏了一行。我有一个com对象读取

文件并将文件内容发送到BinaryWrite。我有什么想法吗?


感谢您的帮助。
Hi Dan,

I added the PDF MIME to the server. It made no difference. I still get
the same error when I click the open or save button. The URL in the
window is of the original ASP page that redirects to PDF file. The PDF
file ("/webserver/pdffiles/myreport.pdf") URL is NOT displayed.

Oh, I left out a line by mistake. I have a com object that reads the
file and send the file content to BinaryWrite. I any ideas?

Thanks for your help.


ma ******* @ yahoo.com 写道:

如果我使用以下代码:

<%

pdfFile =" myreport.pdf";

Response.Clear;

Response.ContentType = " application / pdf";

Response.AddHeader(" Content-Type"," application / pdf");

Response.AddHeader(" content- disposition"," inline; filename =" +

pdfFile);

Response.BinaryWrite(" / website / pdffiles /" + pdfFile);

Response.End;

%>


Acrobat打开并显示以下错误文件无法启动

with''%PDF - ''"。
if I use the following code:
<%
pdfFile = "myreport.pdf";
Response.Clear;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("content-disposition", "inline;filename=" +
pdfFile);
Response.BinaryWrite("/website/pdffiles/" + pdfFile);
Response.End;
%>

Acrobat open and displays the following error "File does not begin
with ''%PDF-''".



Response.BinaryWrite不接受字符串参数。你必须在那里放一个字节

数组。这可能来自ADODB.Stream,记录集或类似内容。

http://msdn.microsoft.com/library/en...adoobjects.asp


典型用途会看起来像:


Response.BinaryWrite(adoStream.Read())

Response.BinaryWrite(adoRecordset.Fields(" FileData")。Value)

Response.BinaryWrite(adoField.GetChunk(size))

-

戴夫安德森


未经请求的商业电子邮件将以

Response.BinaryWrite does not take a string argument. You must put a byte
array in there. This could come from an ADODB.Stream, recordset, or similar.

http://msdn.microsoft.com/library/en...adoobjects.asp

Typical uses would look like:

Response.BinaryWrite(adoStream.Read())
Response.BinaryWrite(adoRecordset.Fields("FileData ").Value)
Response.BinaryWrite(adoField.GetChunk(size))
--
Dave Anderson

Unsolicited commercial email will be read at a cost of


这篇关于重定向到PDF文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆