ASP.NET:覆盖内容类型标头

时间:2013-10-04 20:10:31

标签: asp.net http http-headers iis-7.5 kml

我在 IIS 7.5,Windows 2008 R2 上运行一组 ASP.NET 页面。我可以访问ASP.NET源代码。

每个页面都使用默认的Content-Type标题发布:

Content-Type: text/html; charset=utf-8

但是,这些网页正在生成 KML ,因此应该发出此Content-Type标题:

Content-Type: application/vnd.google-earth.kml; charset=utf-8

我尝试覆盖 IIS管理器中的默认Content-Type标题,如下所示:

默认网站 => 应用 Folder => IIS 群组=> HTTP响应标头 =>的 添加

Add Custom HTTP Response Header
 Name: [Content-Type]
Value: [application/vnd.google-earth.kml; charset=utf-8]

执行此操作后,Content-Type标题已更改,但不是以理想的方式:

text/html; charset=utf-8,application/vnd.google-earth.kml; charset=utf-8

正如您所看到的,我提供的值是追加到现有的Content-Type标头,而不是替换默认的Content-Type标头。

问题:是否有某种方法可以覆盖IIS管理器中的Content-Type标头?或者,是获取ASP.NET源并在那里明确设置Content-Type标头的唯一解决方案吗?

0 个答案:

没有答案
相关问题