Is there a way to execute a code on every page load in ASP.NET Core 5, like there is in Web Forms? In Web Forms I used the Page_Load()
event handler, but what is the equivalent in ASP.NET Core 5? So if I call any action in any controller, it will run my code first, then run the action execution.
I found this: How can I execute common code for every request?, But when I tried it I got errors.
Please someone provide me with clear solution.
Also, I need a solution to check the session from one place, instead of writing the "check session code" in each controller, I create the session after the login is succeed, but what is the best way to check the session in all controllers and if it is null then redirect to login page?