views:

386

answers:

2

How do I read the Response Headers that are being sent down in a page ? I want to be able to read the header values and modify some of them. This is for an ASP.NET 1.1 application but I would be curious to know if it can done in any version of ASP.NET. The reason for doing this is someone may have added custom headers of their own before the point I am examining the response - so I cannot blindly clear all the headers and append my own - I need to read the all the headers so I can modify the appropriate ones only.

A: 

AFAIK it cannot be done in ASP.NET 1.1. There is no way for you to get at the response headers - request headers are available but not response headers. I am not sure if you can do this in other stacks like Java, LAMP though and I am curious to find out...

Nikhil
+1  A: 

HttpContext.Current.Response (Its a HTTPResponse), exposed ClearHeaders(), AddHeaders() and AppendHeaders().

Not as direct as it is now in later version of ASP.NET, but should be enough to let you modify the headers you wanted to modify.

http://msdn.microsoft.com/en-us/library/system.web.httpresponse_members(VS.71).aspx

FlySwat
Th problem is however - if I clear headers I am clearing everything and I may be clearing something someone else has set. So I need a way to check is custom headers are added BEFORE I clear headers and add my own...
Nikhil
I am not sure if my question captures this - I will edit it as well... Thanks for the response though.
Nikhil