我想授予系统管理员和管理员权限,但在我写作时 @if(User.IsInRole("系统管理员","管理员"))得到错误(方法没有重载' IsINRole'带2个参数)尽管在控制器上它是工作
[CustomAuthorize(Roles ="系统管理员,管理员")] public class CategoriesController:Controller
我还有其他方法可以解决这个问题吗?
答案 0 :(得分:0)
您无法将多个角色传递给IsInRole
功能。但您可以使用c#中的||
功能,如下所示。
@if (User.IsInRole("System Administrator") || User.IsInRole("Administrator"))
{
//your code here
}