In ASP.NET Core, how can you enforce an authenticated user to have a specific role to access a resource?

  • Use the [Authorize] attribute with the "Roles" parameter
  • Use the [AllowAnonymous] attribute
  • Use the [Authorize] attribute with the "Permissions" parameter
  • Use the [Authorize] attribute without any parameters
To enforce that only users with a specific role can access a resource, you should use the [Authorize] attribute with the "Roles" parameter. This restricts access to users who belong to the specified role.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *