If you want to specify multiple roles for an action or a controller using the [Authorize] attribute, how would you do it?

  • [Authorize(Roles = "Admin, Manager")]
  • [Authorize(Role = "Admin", Role = "Manager")]
  • [Authorize("Admin, Manager")]
  • [Authorize("Admin", "Manager")]
To specify multiple roles using the [Authorize] attribute, you can separate them with commas inside the Roles parameter, like this: [Authorize(Roles = "Admin, Manager")]. This allows access to the action or controller for users who belong to either the "Admin" role or the "Manager" role or both.
Add your answer
Loading...

Leave a comment

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