I'm trying to run a function every time a user logs in. What I tried is to obtain an instance of AuthenticationStateProvider from the DI container and subscribe to its AuthenticationStateChanged event. The problem is that my login pages are implemented using server-rendered Razor Pages so the page refreshes after a successful login. This means that my code subscribes to the event after it is fired, so my handler function never runs. Can anybody see a way to run custom code upon successful login?