ASP.NET MVC 5: Custom authentication with OnActionExecuting

Although I prefer the AuthorizeAttribute approach, there is another simpler way with a base Controller and OnActionExecuting:

Let’s assume the following Controller:

All you need is a base controller with OnActionExecuting overridden, to check before each action for the proper rights…:

And of course you need to change every Controller of your app to inherit from your base: