Search code examples
asp.net-mvcblazorasp.net-identityblazor-server-side

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.


Solution

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