AddHeader Content-Disposition无效 [英] AddHeader Content-Disposition Has no effect

查看:221
本文介绍了AddHeader Content-Disposition无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个IIS网站,可以在一台服务器上运行,但不能在另一台服务器上运行。我

不知道问题是IIS设置还是别的什么,所以我想b $ b将尽量包含我到目前为止所知的细节。


几个网页允许用户下载要查看的PDF文件,或者在用户机器上本地保存
,而不是在浏览器中保存。这些网页

页面全部重定向到一个带有QueryString参数的ASP页面

标识远程服务器上所需文件的相对路径。


重定向网址如下:


download.asp?Src = Statements\2006\01\123456789


我的download.asp代码看起来像这样:


========================== =======================

Dim strSourceName

Dim objDocServer

''检索所需文件的路径

strSourceName = Request.QueryString(" Src")


''呼叫远程COM +应用程序和检索文档作为二进制流

设置objDocServer = Server.CreateObject(" DocumentServer.Application")

设置objDocServer.Document = objDocServer.getDocument(strSourceName)


回复

.Buffer = True

。清除

.ContentType =" ; application / pdf"

.AddHeader" content-disposition"," attachment; filename = test.pdf;"

.BinaryWrite(objDocServer.Document)

结束

========= ========================================


当我尝试下载文件时,浏览器显示文件下载

对话框,要求我打开或保存文件,但它显示文件名为

" 123456789"而不是test.pdf。它还显示

文件类型的空白值。我是否选择打开或保存相同的错误出现:


Internet Explorer无法从< server>下载123456789.

Internet Explorer无法打开此现场。请求的网站

不可用或无法找到。请稍后再试。


如果我注释掉AddHeader行,则文件类型正确显示为

Adob​​e Acrobat文档。

如果我将AddHeader更改为内联而不是附件,我在浏览器中看到

二进制数据。


这个确切的代码工作正常在另一台服务器上,我不知道为什么它会在这台新服务器上运行
。我觉得有趣的是,

下载想要将文件命名为123456789,它来自一个部分

一个QueryString值,而不是其他地方。这有什么可做的吗

与\ QueryString中的字符被IIS / ASP混淆为路径

分隔符?


感谢任何想法或帮助!


Michael

I have a IIS web site that works fine on one server but not another. I
do not know if the problem is an IIS setting or something else so I
will try to include as much detail as I have figured out so far.

Several web pages allow the user to download PDF files to be viewed or
saved locally on the user''s machine, not in the browser. Those web
pages all redirect to a single ASP page with QueryString parameters
identifying the relative path to the desired file on a remote server.

The redirect URL would be something like:

download.asp?Src=Statements\2006\01\123456789

My download.asp code looks something like this:

=================================================
Dim strSourceName
Dim objDocServer

'' Retrieve the path to the desired document
strSourceName = Request.QueryString("Src")

'' Call remote COM+ application and retrieve document as binary stream
Set objDocServer = Server.CreateObject("DocumentServer.Application")
Set objDocServer.Document = objDocServer.getDocument(strSourceName)

With Response
.Buffer = True
.Clear
.ContentType = "application/pdf"
.AddHeader "content-disposition", "attachment; filename=test.pdf;"
.BinaryWrite(objDocServer.Document)
End With
=================================================

When I try to download a file, the browser shows the File Download
dialog asking me to Open or Save the file but it shows the File name as
"123456789" rather than "test.pdf". It also shows a blank value for the
File type. Whether I choose Open or Save the same error appears:

Internet Explorer cannot download 123456789 from <server>.
Internet Explorer was not able to open this site. The requested site is
either unavailable or cannot be found. Please try again later.

If I comment out the AddHeader line, the File type shows correctly as
Adobe Acrobat Document.

If I change the AddHeader to inline rather than attachment, I see the
binary data in the browser.

This exact code works fine on another server and I have no idea why it
will not work on this new server. What I find interesting is that the
download wants to name the file as 123456789 which comes from a part of
a QueryString value and nowhere else. Could this have something to do
with the "\" characters in the QueryString being confused as path
delimiters by IIS/ASP?

Any ideas or help are appreciated!

Michael

推荐答案

如果您尝试删除;,该怎么办?在内容中的文件名后

处置标题?


-

Patrice


< Mi ***** @MichaelLevy.netaécritdansle message de news:
11 ********************* @ 75g2000cwc.googlegroups.co m ...
Also what if you try to remove the ";" after the filename in the content
disposition header ?

--
Patrice

<Mi*****@MichaelLevy.neta écrit dans le message de news:
11*********************@75g2000cwc.googlegroups.co m...

>我有一个IIS网站,可以在一台服务器上运行,但不能在另一台服务器上运行。我

不知道问题是IIS设置还是别的什么,所以我想b $ b将尽量包含我到目前为止所知的细节。


几个网页允许用户下载要查看的PDF文件,或者在用户机器上本地保存
,而不是在浏览器中保存。这些网页

页面全部重定向到一个带有QueryString参数的ASP页面

标识远程服务器上所需文件的相对路径。


重定向网址如下:


download.asp?Src = Statements\2006\01\123456789


我的download.asp代码看起来像这样:


========================== =======================

Dim strSourceName

Dim objDocServer

''检索所需文件的路径

strSourceName = Request.QueryString(" Src")


''呼叫远程COM +应用程序和检索文档作为二进制流

设置objDocServer = Server.CreateObject(" DocumentServer.Application")

设置objDocServer.Document = objDocServer.getDocument(strSourceName)


回复

.Buffer = True

。清除

.ContentType =" applic ation / pdf"

.AddHeader" content-disposition"," attachment; filename = test.pdf;"

.BinaryWrite(objDocServer.Document)

结束

========= ========================================


当我尝试下载文件时,浏览器显示文件下载

对话框,要求我打开或保存文件,但它显示文件名为

" 123456789"而不是test.pdf。它还显示

文件类型的空白值。我是否选择打开或保存相同的错误出现:


Internet Explorer无法从< server>下载123456789.

Internet Explorer无法打开此现场。请求的网站

不可用或无法找到。请稍后再试。


如果我注释掉AddHeader行,则文件类型正确显示为

Adob​​e Acrobat文档。

如果我将AddHeader更改为内联而不是附件,我在浏览器中看到

二进制数据。


这个确切的代码工作正常在另一台服务器上,我不知道为什么它会在这台新服务器上运行
。我觉得有趣的是,

下载想要将文件命名为123456789,它来自一个部分

一个QueryString值,而不是其他地方。这有什么可做的吗

与\ QueryString中的字符被IIS / ASP混淆为路径

分隔符?


感谢任何想法或帮助!


Michael
>I have a IIS web site that works fine on one server but not another. I
do not know if the problem is an IIS setting or something else so I
will try to include as much detail as I have figured out so far.

Several web pages allow the user to download PDF files to be viewed or
saved locally on the user''s machine, not in the browser. Those web
pages all redirect to a single ASP page with QueryString parameters
identifying the relative path to the desired file on a remote server.

The redirect URL would be something like:

download.asp?Src=Statements\2006\01\123456789

My download.asp code looks something like this:

=================================================
Dim strSourceName
Dim objDocServer

'' Retrieve the path to the desired document
strSourceName = Request.QueryString("Src")

'' Call remote COM+ application and retrieve document as binary stream
Set objDocServer = Server.CreateObject("DocumentServer.Application")
Set objDocServer.Document = objDocServer.getDocument(strSourceName)

With Response
.Buffer = True
.Clear
.ContentType = "application/pdf"
.AddHeader "content-disposition", "attachment; filename=test.pdf;"
.BinaryWrite(objDocServer.Document)
End With
=================================================

When I try to download a file, the browser shows the File Download
dialog asking me to Open or Save the file but it shows the File name as
"123456789" rather than "test.pdf". It also shows a blank value for the
File type. Whether I choose Open or Save the same error appears:

Internet Explorer cannot download 123456789 from <server>.
Internet Explorer was not able to open this site. The requested site is
either unavailable or cannot be found. Please try again later.

If I comment out the AddHeader line, the File type shows correctly as
Adobe Acrobat Document.

If I change the AddHeader to inline rather than attachment, I see the
binary data in the browser.

This exact code works fine on another server and I have no idea why it
will not work on this new server. What I find interesting is that the
download wants to name the file as 123456789 which comes from a part of
a QueryString value and nowhere else. Could this have something to do
with the "\" characters in the QueryString being confused as path
delimiters by IIS/ASP?

Any ideas or help are appreciated!

Michael





Patrice写道:

Patrice wrote:

如果您尝试删除;,该怎么办?在内容中的文件名之后

处置标题?
Also what if you try to remove the ";" after the filename in the content
disposition header ?



这没什么区别。我最初没有使用分号,但是在看到这样的例子之后又添加了b $ b。无论哪种方式,它都可以在一个

环境中工作,但不能在另一个环境中工作。

That makes no difference. I originally did not have the semi-colon but
added it after seeing such in an example. Either way, it works on one
environment but not another.




< Mi *****@MichaelLevy.net写信息

新闻:11 ********************* @ 75g2000cwc.googlegrou ps.com ...

<Mi*****@MichaelLevy.netwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...

>

Patrice写道:
>
Patrice wrote:

还有什么如果您尝试删除;,在内容中的文件名之后

处置标题?
Also what if you try to remove the ";" after the filename in the content
disposition header ?



这没什么区别。我最初没有使用分号,但是在看到这样的例子之后又添加了b $ b。无论哪种方式,它都适用于一个

环境,但不适用于另一个环境。


That makes no difference. I originally did not have the semi-colon but
added it after seeing such in an example. Either way, it works on one
environment but not another.



您是否尝试过使用没有\\的网址?在查询字符串中?

您是否尝试将\转义为%5C?

这两台服务器是否在同一操作系统和同一服务包上?

已检查页面是否没有添加其他标题或

文件夹属性?

Have you tried using a URL that doesn''t have \ in the query string?
Have you tried escaping the \ as %5C ?
Are the two servers on the same OS and at the same service pack?
Have checked that are no additional headers being added by the page or
folder properties?


这篇关于AddHeader Content-Disposition无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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