I use the Authorize attribute to filter controller actions based on user roles, but if an unauthorized action is attempted, the user is redirected back to the login page. As a user, I would find this confusing and annoying.
How can I instead display an error message informing the user about the need for certain roles and stay in the view where they tried to perform the action?
source
share