Hi,
NOTE: version 8.0
There's a session variable I'd like to update on every single non-admin webpage load. (It's okay if the session variable is updated on an admin webpage load ... but it doesn't need to be.)
Which handler would you recommend for that? Many of these handlers only run under specific conditions ... I'm not sure which handler would run on every webpage load?
I tried to add the session update code to CMSModuleHandler's init() method ... but it causes an error, I'm guessing the session isn't set up yet?
Thanks, Rita.
What you looking is Handling Global Events and Global System Events - Request Events
[CustomRequestEventsHandler] public partial class CMSModuleLoader { /// <summary> /// Attribute class that ensures the loading of custom handlers /// </summary> private class CustomRequestEventsHandlerAttribute : CMSLoaderAttribute { /// <summary> /// Called automatically when the application starts /// </summary> public override void Init() { /// <summary> /// Occurs when the request processing starts. /// RequestEvents.Prepare.Begin += (sender, args) => { // Manipulate your session variables } } } }
Not sure you'd use an event handler. Create a public static property. Or even better yet, create a webpart and place it on your master page which will get or set your session variable. Doing this will allow you to set some other properties like if you want to turn it on or off at all from the UI.
Thank you, Brenden, I didn't think of using a webpart.
I've been working on a couple of security handlers, and kinda got tunnel vision :).
Excellent, thank you, Peter!
Please, sign in to be able to submit a new answer.