Skip to content
Discussion options

You must be logged in to vote

I remember reading someone's comment somewhere in this repo that you can use the Handler lifecycle for one-time "setup/teardown" methods. I don't remember where I saw it though.

This is what I use:

Create an extension so it's kept clean:

public static class HandlerChangingEventArgsExtension
{
    public static bool AttachingToHandler(this HandlerChangingEventArgs args)
    {
        return args.NewHandler != null && args.OldHandler == null;
    }

    public static bool DetachingFromHandler(this HandlerChangingEventArgs args)
    {
        return args.NewHandler == null && args.OldHandler != null;
    }
}

Create some base class for the Pages you use and override OnHandlerChanging:

protected 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by prabhavmehra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants