tags:

views:

64

answers:

2

I read somewhere the you can't remove response headers once they've been added. Given that, I'm wondering where in a standard ASP.NET web forms application do response headers get added initially. For example, these:

Date Fri, 23 Apr 2010 16:25:56 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET
Cache-Control private

And can I stop it from happening? Do subsequent headers override old headers? Does my question even make sense?

Thanks.

A: 

The X-Powered-By: ASP.NET header is added by IIS. You can remove this globally or on a per site bases by editing 'Custom HTTP Headers' on the HTTP Headers tab.

Kev
Thanks for your response. It was very helpful, but I'm still searching for a more complete answer.
Jones
+2  A: 

The headers you mentioned are added automatically by IIS. Instructions for changing them are at a question posted on Serverfault here.

But to answer your question about when, I believe you're remembering what you read wrong.

I believe what you are referring to is that you can't modify any http headers once content has been sent back to the browser. This would happen in the Rendering event OR as soon as you use a Response.Write or Response.Redirect method.

Edit - added

Incidentally, there are a number of things you can't do oncew the headers have been sent... Modifying cookies, using a Response.Redirect, etc

See these links:

http://stackoverflow.com/questions/159523/why-do-i-get-cannot-redirect-after-http-headers-have-been-sent-when-i-call-resp

http://www.bing.com/search?q=HTTP+headershave+been+sent&src=IE-SearchBox&FORM=IE8SRC

Added even more

And finally - a better answer. I was looking for an event in the page lifecycle where the httpheaders are sent. Actually, they are sent by the HttpApplication object. The event that fires just before this is the PreSendRequestHeaders event per this article.

David Stratton
Now I'm done. That's enough edits for one answer.
David Stratton