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.
Loading...
Related Quiz
- In scenarios with table splitting in Entity Framework Core, how is it ensured that multiple entities map to a single table?
- In a route template, _______ are used to define optional parameters.
- The process of mapping an incoming request to a route template is known as _______.
- When dealing with complex forms in Razor, which approach allows for grouping related form fields into smaller, reusable views?
- How can you define a route in ASP.NET Core to be available only for specific HTTP methods using attribute routing?