Role-Based Authorization in ASP.NET Core MVC
This blog is going to explain what Role-Based Authorization is and how it can be implemented in ASP.NET Core MVC. The Authorization is a process of controlling which page the logged-in user can access. Role-Based Authorization authorizes the user based on the user's roles. Let's see how to achieve it step by step. Step 1: The first step is to make sure that the Authorization middleware is included in the Configure method of Startup.cs file . Authentication middleware checks whether the user has permission to place a request for the application. If the user has permission then it will allow creating a response. Authorization middleware should come after Authentication middleware as shown in the code below. Startup.cs public void Configure( IApplicationBuilder app, IWebHostEnvironment env) { ... ... ... app.UseAuthentication(); app.UseAuthorization(); ... ... ... } Step 2: In this step, I have created the Users class. It has thr