From the course: ASP.NET Core Identity: Authorization Management

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Adding role checks

Adding role checks - ASP.NET Core Tutorial

From the course: ASP.NET Core Identity: Authorization Management

Start my 1-month free trial

Adding role checks

- [Instructor] We learned on the last part about simple authorization, which is an authorization type to check if a user is authenticated or not. On this part, we will talk about the role-based authorization and how to add role checks to check if a user belongs to a certain role. So let us go to Visual Studio and see how we can add role checks to our .NET Core MVC application. In our folder, go to the Controllers folder and inside here, go to the HomeController.cs file. We said that if we put an authorization built in here, it means that the users to be able to access the Admin, Student, or Teacher dashboard, they need to be authenticated. So let us run this project. If we go to any of these sections, so we got Teachers, Students, or even Admin, we cannot access it because we need to be authenticated. Now, let us go to Register and create a new account. Click the Register button to create this account. Now that we created the account and we were successfully logged in, we see that we…

Contents