Reputation: 4811
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
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
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