标头出现在浏览器中,但在Response对象中丢失 [英] Headers appear in browser but are missing in Response object
问题描述
我有一个运行在IIS 7.5上的.NET应用程序,返回了以下响应标头,如Chrome的网络页面所示:
I have a .NET application running on IIS 7.5 with the following response headers returned, as shown on Chrome's network page:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 21 Sep 2012 16:11:55 GMT
Content-Length: 840
在C#代码中,我尝试读取这些响应标头,但是 HttpContext.Response.Headers
检索到的仅有以下两个标头:
In the C# code I try to read those response headers, but the only ones retrieved by HttpContext.Response.Headers
are the following two:
- 服务器:Microsoft-IIS/7.5
- X-AspNetMvc版本:3.0
不用说, HttpContext.Response.Headers.AllKeys.Length
和 HttpContext.Response.Headers.Keys.Count
都返回2.
由于在生产环境中,应用程序将不得不读取一个额外的响应标头,即动态响应标头,因此我需要能够拦截所有这些标头.
Since in the production environment the application will have to read an extra response header, a dynamic one, I need to be able to intercept ALL those headers.
一个解决方案将不胜感激.
A solution would be greatly appreciated.
推荐答案
这些标头在IIS 7.5上是 private
Theses headers are private
on IIS 7.5
您可以通过执行以下步骤来添加 Response Header
:
You can add a Response Header
by executing theses steps:
-
打开您的
IIS管理器
,导航到您要管理的级别.
Open your
IIS Manager
, navigate to the level you want to manage.
在"<代码>功能视图" 中,双击""HTTP响应头""
功能.
在操作"面板上单击添加..."
Click "Add…" on the Actions Panel
这篇关于标头出现在浏览器中,但在Response对象中丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!