Mickey
Mickey

Reputation: 11

Headers appear in browser but are missing in Response object

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

In the C# code I try to read those response headers, but the only ones retrieved by HttpContext.Response.Headers are the following two:

Needless to say, both HttpContext.Response.Headers.AllKeys.Length and HttpContext.Response.Headers.Keys.Count return 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.

Upvotes: 1

Views: 2195

Answers (1)

Aghilas Yakoub
Aghilas Yakoub

Reputation: 29000

Theses headers are private on IIS 7.5

You can add a Response Header by executing theses steps:

  1. Open your IIS Manager, navigate to the level you want to manage.

  2. In Features View, Double click “HTTP Respond Headers” feature.

  3. Click “Add…” on the Actions Panel

Upvotes: 1

Related Questions