When are response headers created in ASP.NET web forms?

I read somewhere that you cannot delete response headers after adding them. Given this, I am wondering where in the standard ASP.NET web form application, response headers are first added. For example, they:

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? Do subsequent headers write down old headers? Does my question make sense?

+4
source share
2 answers

The headers you mentioned are automatically added by IIS. Instructions for changing them can be found on the question posted on Serverfault here .

But to answer your question about when, I believe, you remember that you are reading incorrectly.

I believe that you mean that you cannot change the http headers after the content has been sent back to the browser . This will happen in the Rendering event or as soon as you use the Response.Write or Response.Redirect method.

Edit - Added

By the way, there are a few things you cannot do once the headers are sent ... Modifying cookies with Response.Redirect, etc.

See these links:

Why do I get "Can't redirect after sending HTTP headers" when I call Response.Redirect ()?

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

Added even more

And finally, the best answer. I was looking for an event in the life cycle of the page where the HTTP headers are sent. In fact, they are dispatched by the HttpApplication object. The event that fires before this is the PreSendRequestHeaders event in this article .

+3
source

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

+2
source

Source: https://habr.com/ru/post/1307797/


All Articles