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.
Loading...
Related Quiz
- How does the "Controller" in the MVC design pattern typically receive user input in ASP.NET Core?
- What is the primary role of Entity Framework Core in ASP.NET Core applications?
- You want to use a database with your ASP.NET Core web application. Which ORM (Object-Relational Mapping) framework is natively supported by ASP.NET Core for this purpose?
- To override the default routing conventions in MVC, you can use the _________ attribute on your action methods.
- Which attribute would be used to enforce that a specific route parameter should be of type integer?