Take a look at how we've done this on uComponents with the UI modules - we couldn't find a direct way to hook into the Page Events, so ended up using a HttpModule to do it.
Here's some additional information I've discovered.
I created a class based on the IHttpModule interface... works great when registered in the web.config
No problem.. right? Well there is in my case. I didn't want to have to add the registration to the web.config during the package install.. I like things to run as a single unit and this sort of added an additional step to my thought process and I didn't like it.
After searching the net, I came upon a wonderful solution to my "problem"... I can now register my HttpModule dynamically in my code which is what I wanted.
This is how to do it:
Add a reference to Microsoft.Web.Infrastructure and be sure to add the assembly to your package so it's copied to the bin folder. Create a static method in a class (mine's in the class that inherits from ApplicationBase callled ApplicationEventsHandler since I attach to other events there)
The DynamicModuleUtility.RegisterModule method will register your HttpModule on PreApplicationStart and removes the need to register the modules in web.config.
Note: this only works with .Net 4.0... haven't tested with 3.5.
Attach to umbraco.aspx Load Event
I need to insert dynamic javascript into umbraco.aspx
What is the easiest way to attach to the Load even for /umbraco/umbraco.aspx.
I can do this with pages based on umbracoPage class, but not the umbraco.aspx.
Any direction would be helpful.
Hi Daniel,
Take a look at how we've done this on uComponents with the UI modules - we couldn't find a direct way to hook into the Page Events, so ended up using a HttpModule to do it.
http://ucomponents.codeplex.com/SourceControl/changeset/view/72953#1411916
Cheers, Lee.
Lee,
Thanks.. I'll have a look... odd.. I didn't know that default.aspx transfered to umbraco.aspx
This is helpful.
That worked!!! Thanks!
Q: Why doesn't BasePage.Current.Load work?
Here's some additional information I've discovered.
I created a class based on the IHttpModule interface... works great when registered in the web.config
No problem.. right? Well there is in my case. I didn't want to have to add the registration to the web.config during the package install.. I like things to run as a single unit and this sort of added an additional step to my thought process and I didn't like it.
After searching the net, I came upon a wonderful solution to my "problem"... I can now register my HttpModule dynamically in my code which is what I wanted.
This is how to do it:
Add a reference to Microsoft.Web.Infrastructure and be sure to add the assembly to your package so it's copied to the bin folder.
Create a static method in a class (mine's in the class that inherits from ApplicationBase callled ApplicationEventsHandler since I attach to other events there)
Then add the following call to your class file (before your class declaration)
The DynamicModuleUtility.RegisterModule method will register your HttpModule on PreApplicationStart and removes the need to register the modules in web.config.
Note: this only works with .Net 4.0... haven't tested with 3.5.
Here's a link to the blog post that saved me: http://www.paraesthesia.com/archive/2011/02/08/dynamic-httpmodule-registration-in-asp-net-4-0.aspx
Hope this was helpful to all you package developers!
is working on a reply...