相关疑难解决方法(0)

在视图中使用User.IsInRole()

在我的mvc5项目中禁用未授权用户的操作链接我确实喜欢这个

@if (User.IsInRole("Admin") | User.IsInRole("Manager"))
{ 
        @Html.ActionLink("Add New Record", "ProductTypeIndex", "ProductType")
} 
Run Code Online (Sandbox Code Playgroud)

但如果要检查的角色很多,那么@if()会变长.怎么避免这个?我是否需要定制助手(如果是这样,我该如何处理它)?帮助赞赏..

isinrole asp.net-mvc-5 asp.net-identity-2

11
推荐指数
1
解决办法
1万
查看次数