How do I track every time a user connects (with a cached login)?

I want to track every time a user connects to my app (saving the DateTime and remote IP). This is easy when they have to log in.

But, I use the ASP.NET Core Identity Library and it saves the login authentication (in a cookie I believe) so that a user does not need to re-enter their credentials when returning.

How can I get an event or otherwise intercept that it has just authenticated a user for a new session?

My app is Blazor server side and the ASP.NET Identity Library is MVC.

  • Maybe a scoped service in say App.razor that checks authentication state and logs the information.

    – 

  • @MrCakaShaunCurtis I was thinking way too complicated. That is a very elegant solution – the service is instantiated for each circuit which is when I want to do this. If you make that an answer, happy to accept it. Thanks

    – 

Maybe a scoped service in say App.razor that checks authentication state and logs the information.

Leave a Comment