cool breeze
cool breeze

Reputation: 4811

When method to override in asp.net base page to set http header?

I have a base class where I want to set a custom http header for all my pages that inhert from this base page class.

What method should I override in the base class to set a http header?

Upvotes: 0

Views: 217

Answers (2)

Michel
Michel

Reputation: 56

OnPreRender is the method you want to override. It occurs after the Init and Load events. You will then certainly avoid having your base page custom header being overriden by a derived page.

For more informations, see msdn resource.

Upvotes: 2

Markus
Markus

Reputation: 22456

I'd propose to override the OnPreRender method. It is one of the last methods that are called before the response is sent to the client. So even if you only want to set the header under certain conditions, you need to be able to evaluate the conditions at this point in the page lifecycle.

Upvotes: 0

Related Questions