From the course: ASP.NET Core: Token-Based Authentication
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Adding multiple roles to a controller - ASP.NET Core Tutorial
From the course: ASP.NET Core: Token-Based Authentication
Adding multiple roles to a controller
- [Instructor] On the last part, you added the role-based authentication in your controller. You updated the Student controller so it's accessible just by the Student role and the management controller just by the Manager role. But in the identity framework, it's also possible to add multiple roles in the same controller. You can have different roles which access all the API endpoints, or you can have different roles accessing different API endpoints within the same controller. Let us go to Visual Studio and see it in action. In Visual Studio, we are going to modify the HomeController and in the authorize attribute, we are going to add the Student and the Manager roles. So for that in here I'll just type roles and the roles need to be a format string and then separated by a comma. So the first role is going to be user roles and then let us just import the space, then in here, .Student. Now let us join these two roles…