C# ASP.NET内核中基于角色的授权

C# ASP.NET内核中基于角色的授权,c#,sql,asp.net-core,C#,Sql,Asp.net Core,我为用户提供了以下模式: [Id], [Name], [Email], [Password], [RoleId] RoleId必须值(1,2)=>1:is admin,2:is student user 如果等于1,如何通过RoleId在adminController.cs中应用授权 如果RoleId=2未经授权。以下是自定义授权策略提供程序的Microsoft文档:

我为用户提供了以下模式:

[Id],
[Name],
[Email],
[Password],
[RoleId]
RoleId必须值(1,2)=>1:is admin,2:is student user

如果等于1,如何通过RoleId在adminController.cs中应用授权


如果RoleId=2未经授权。

以下是自定义授权策略提供程序的Microsoft文档: