Response.AddHeader(QUOT;内容处置" .... [英] Response.AddHeader("Content-Disposition"....

查看:77
本文介绍了Response.AddHeader(QUOT;内容处置" ....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在输出'的创作中有这样的陈述:


Response.Clear()


Response.ContentType = " application / vnd.google-earth.kml + xml kml"

Response.AddHeader(" Content-Disposition"," inline; filename = Log _"&

activityLogID&" .kml")

我的开发服务器上的所有工作都是有效的(IE尝试打开
$ b $使用GE的b文件,如果我点击链接时强制它保存文件,

它会提示输入Log _.....文件名。但是在生产服务器上,IE没有b $ b识别MIME类型,如果我强制它保存文件,它会提示输入

原始aspx文件名称。

Firefox在所有两台服务器上运行良好。哪里有错误?


谢谢

解决方案

" Steven Cheng [MSFT] " < st ***** @ online.microsoft.com写信息

新闻:ha ************* @ TK2MSFTNGXA01.phx.gbl ...


Hello Trapulo,


从您的描述中,您正在使用ASP.NET页面清除一些谷歌

地球地图文件,让客户端选择谷歌地球,但是,你发现这在开发服务器上运行应用程序时有效吗

但是

在生产服务器上运行时不起作用,对吗?



yes


至于不同的行为,你是否在同一个客户端上获取它们

机器访问服务器页面或只是在每台服务器上本地测试?

我建议你尝试不同的远程客户端机器来查看是否

你''会得到不同的行为。



我试用同一台机器,也就是开发服务器。我也从其他机器尝试了
,但只调用生产服务器,而且我的b $ b具有相同的行为。


根据我的经验,客户端浏览器对

处理

不同mime-type的行为取决于其内部实现。对于IE,你可以查看下面的msdn文章:


Internet Explorer中的#MIME类型检测
http://msdn.microsoft.com/workshop/n.../ appendix_a.as

p?frame = true



我认为问题可以在这里:

如果找到肯定匹配(其中一个硬编码测试成功),这个

MIME类型会立即返回作为最终决定,覆盖

服务器提供的MIME类型(这种行为对于识别作为text / html发送的

..gif文件是必要的)。在扫描期间,确定

缓冲区是否主要是文本或二进制。


可能是IE扫描内容,并且看到它是一个xml文件。所以它显示为

xml,忽略了mime指令。如果这可以解释问题(然后我

不知道如何解决它,因为这是xml,但是IE可能会打开正确的

viewer),这个并没有解释为什么在生产服务器上调用页面

有效。


如果问题是特定于服务器的,你可以在IIS 6的服务管理器中查看已注册的

mime-type(请参阅我在此

消息中附带的屏幕截图)。您需要在IIS管理器中选择topest(机器)节点,然后右键单击以选择属性。菜单。



是的,我知道这一点。但是如果我从aspx生成kml格式,我认为

MIME类型是无用的,不是吗?事实上,无论是在我的开发

服务器上,我都找不到与此格式相关的设置。两台服务器之间唯一的区别是两个服务器是开发人员安装了google earth,

但是我觉得奇怪的是它可以改变IIS的行为..


以及文件名问题,如果您选择

代码

,那么行为是什么,如下所示:


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

Response.ClearHeaders();

Response.ClearContent();


Response.ContentType =" application / vnd.google-earth.kml + xml kml"


Response.AddHeader(" Content-Disposition"," attachment; filename = Log_"&

activityLogID&" .kml")
<
===================


这将始终提示文件打开或保存。



我试试这个,但是我的要求是直接打开文件而不是

保存它。但是,它可以是一个可以接受的权衡,如果这可以与IE

一起使用,而不是与Firefox一起使用。


谢谢


感谢您的回复Trapulo,


如果您在同一个客户机上得到不同的结果

不同目标服务器。响应流仍然可能包含

不同的内容/标题。对于那些IIS服务器的mime类型设置,它们实际上是从服务器机器的注册表中读取的。另外,你提到
提到两台服务器的区别在于开发

服务器安装了google earch而部署机器没有,你可以

检查两台机器上的mime类型列表是否也有所不同。


对于一般测试,我认为你可以尝试在IIS中放置静态kml文件

virual diretory并使用浏览器导航到它,看看客户端如何通过b
浏览器处理它。您还可以使用一些网络跟踪工具来捕获两个不同响应的http响应流(正确且

不正确),以查看其中的差异是什么原始回复。


此致,

Steven Cheng


Microsoft MSDN在线支持主管

此帖子按原样提供。没有保证,也没有授予任何权利。




" Steven Cheng [MSFT]" < st ***** @ online.microsoft.com写信息

新闻:4R ************** @ TK2MSFTNGXA01.phx.gbl ...


感谢您的回复Trapulo,


如果您在同一个客户机上取得不同的结果,那么

不同的目标服务器。响应流仍然可能包含

不同的内容/标题。对于那些IIS服务器的mime类型设置,它们实际上是从服务器机器的注册表中读取的。另外,你提到
提到两台服务器之间的区别在于开发

服务器安装了google earch而部署机器没有,你是

可以

检查两台机器上的mime类型列表是否也有所不同。



我试图在我的开发服务器上找到一些特定的设置,但是它似乎GE没有定义任何设置(实际上,它看起来似乎是合理的:它可以更新IIS设置是非常奇怪的。) 。)。


对于一般测试,我认为你可以尝试在IIS中放置静态kml文件

virual diretory并使用浏览器导航到它看看客户端如何通过b $ b $浏览器处理它。



这怎么办?如果这两台服务器没有任何与kml相关的mime设置,那么
IIS无法流式传输任何标头..


你也可以使用一些网络跟踪工具来捕获


两个不同响应的http响应流(正确且

不正确),看看原始的差异是什么响应。



你能建议我可以使用的任何简单工具吗?我不是吗,我不知道

我可以使用什么


但是,我已经用附件检查过了而不是内联在

content.disposition(如你所建议的),如果我选择打开,IE将启动谷歌地球并显示

文件。当它询问是否打开或保存文件时。这是一个
的解决方法,它不是真正的解决方案,但它仍然是一步之遥。


谢谢


I''ve this statement in my output''s creation:

Response.Clear()

Response.ContentType = "application/vnd.google-earth.kml+xml kml"

Response.AddHeader("Content-Disposition", "inline; filename=Log_" &
activityLogID & ".kml")

The strage is that on my development server all works (IE try to open the
file with GE, and if I force it to save the file when I click on the link,
it prompts for "Log_....." file name). But on production server, IE doesn''t
recognize MIME type, and if I force it to save the file, it prompts for the
original aspx''s file name.
Firefox works well on all two servers. Where is the error?

thanks

解决方案

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:ha*************@TK2MSFTNGXA01.phx.gbl...

Hello Trapulo,

From your description, you''re using ASP.NET page to flush out some google
earth map file and let the client-side choose the google earth, however,
you found this works when running the application on development server
but
not work when running on a production server ,correct?

yes

As for the different behavior, are you getting them on the same client
machine when visiting the server page or just test locally on each server?
I would recommend you try different remote client machine to see whether
you''ll get different behavior.

I try from the same machine, that is also the development server. I''ve also
tried from other machines, but only calling the production server, and I
have the same behavior.

Based on my experience, the client-side browser''s behavior against
handling
different mime-type is depend on its internal implementation. For IE, you
can have a look at the following msdn article:

#MIME Type Detection in Internet Explorer
http://msdn.microsoft.com/workshop/n.../appendix_a.as
p?frame=true

I think the problem can be here:
"If a positive match is found (one of the hard-coded tests succeeded), this
MIME type is immediately returned as the final determination, overriding the
server-provided MIME type (this type of behavior is necessary to identify a
..gif file being sent as text/html). During scanning, it is determined if the
buffer is predominantly text or binary."

maybe IE scan content, and see that it is an xml file. So it shows it as
xml, ignoring mime directive. If this can explain the problem (and then I
don''t know how to solve it because this is xml, but IE may open with right
viewer), this doesn''t explain why calling the page on the production server
works.

And if the problem is specific to server, you can check the registered
mime-type in IIS 6''s service manager(see my attached screenshot in this
message). You need to select the topest(machine) node in IIS manager and
right click to choose "properties" menu.

Yes, I know this. But if I am generating the kml format from aspx, I think
that MIME types are unuseful, aren''t them? In fact, either on my development
server I cannot find a setting related to this format. The only difference
between two servers is that the development one has google earth installed,
but I think it''s strange it can change IIS behavor..

and as for the filename problem, what''s the behevior if you choose the
code
as below:

========================
Response.ClearHeaders();
Response.ClearContent();

Response.ContentType = "application/vnd.google-earth.kml+xml kml"

Response.AddHeader("Content-Disposition", "attachment; filename=Log_" &
activityLogID & ".kml")

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

this will always prompt for file open or save.

I try this, however my requirenment is to open direct the file and not to
save it. However, it can be an acceptable tradeoff if this can work with IE
also, and not with firefox.

thanks


Thanks for your reply Trapulo,

If you get the different results on the same client machie against
differetn target server. It is still likely the response stream contains
different content/headers. As for those IIS server mime-type setting,
they''re actually read from the server machine''s registry. Also, you
mentioned that the difference between the two servers is that development
server has google earch installed while the deployment machine not, you can
check whether the mime-type lists on the two machines also vary.

For general testing, I think you can try put a static kml file in IIS
virual diretory and use browser to navigate to it to see how the client
browser process it. You can also use some network trace tools to capture
the http response stream of the two different response(correct and
incorrect) to see what''s the difference in the raw response.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.



"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:4R**************@TK2MSFTNGXA01.phx.gbl...

Thanks for your reply Trapulo,

If you get the different results on the same client machie against
differetn target server. It is still likely the response stream contains
different content/headers. As for those IIS server mime-type setting,
they''re actually read from the server machine''s registry. Also, you
mentioned that the difference between the two servers is that development
server has google earch installed while the deployment machine not, you
can
check whether the mime-type lists on the two machines also vary.

I tried to find some specific settings on my development server, but it
seems that GE has not defined any setting (and, in fact, it seems
reasonable: it''s very strange that it can update IIS settings..).

For general testing, I think you can try put a static kml file in IIS
virual diretory and use browser to navigate to it to see how the client
browser process it.

how can this work? If the two servers haven''t any kml related mime setting,
IIS cannot stream any header..

You can also use some network trace tools to capture

the http response stream of the two different response(correct and
incorrect) to see what''s the difference in the raw response.

Can you suggest any simple tool I can use? I haven''t it and I don''t know
what can I use

However, I''ve checked that with "attachment" instead of "inline" in
content.disposition (as you suggested), IE starts google earth and shows the
file if I select "open" when it asks if open or save the file. It''s a
workaround and it''s not the real solution, but it''s still a step away.

thanks


这篇关于Response.AddHeader(QUOT;内容处置&QUOT; ....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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