Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top