I have an ASP MVC 5 application and I've noticed that logged in user can still access the registration and login pages. I've also noticed that when a logged in user tries to access a controller action to which they are not authorized, they are redirected to the login page. This is confusing because the user is already logged in.
How do I fix this so that unauthorised redirects to some other 401 error page or view.
On registration/login page, you can redirect logged users :
And if you use role, you can override the
AuthorizeAttribute
AuthorizeRoleAttribute.cs
Edit: Override HandleUnauthorizedRequest