'subscribing to Blazor AuthenticationStateChanged

I could not find any example of how to use the AuthenticationStateChanged in blazor.

My intention is that any page where i want to react to user login or logout i will use these code. I could not find any example on how to implement the event. the one that i tried just keeps on firing for infinite times.

_CustomAuthProvider.AuthenticationStateChanged += AuhtenticationStateChanged;

private async void AuhtenticationStateChanged(Task task) { //This keeps on executing in in loop. }



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source