c# authorize attribute users code example
Example 1: c# authorize attribute roles
[Authorize(Roles = "HRManager,Finance")]
public class SalaryController : Controller
{
}
Example 2: c# authorize attribute
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>()
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddControllersWithViews();
services.AddRazorPages();
}