Curently I use
– context.PreRequestHandlerExecute for changing the masterpage dynamically
– Context.BeginRequest for SEO optimalization
There is some help at HTTPModule Event Execution Order?
Thanks for any tip. Cheers, X.
Here's how I implemented what you are doing without a HttpModule. I didn't like the httpmodule idea because if I forgot to register it and it wasn't running, my app wouldn't work and it would have been a non obvious bug. The page absolutely needs the JS included so I decided to put it in the base Page class of the project.
I implemented this years ago, and wanted to be able to include more than just scripts, it supports css, meta tags, etc.... I forget why I used Page.Header.Controls.Add instead of just Page.ClientScript.RegisterClientScriptInclude but there was a reason.