Redirect user based on roles (without running OnGet)

74 views Asked by At

Users for my ASP.NET Core application have different roles. And different roles have access to different pages.

I've implemented policies and correctly authorized various folders for the related roles.

But I also need to redirect some users to a different area so they see the pages they are supposed to instead of just getting an Access Denied error.

I know I can use User.IsInRole() from my regular Index file and redirect them to the correct pages, but I think I'd prefer that they can never even load a page they don't have access to. And I'd prefer to disable my regular Index file to these users altogether.

How would I do this? Is this already supported using policies, etc.? Or do I need to write some sort of middleware?

0

There are 0 answers