本文介绍了基于用户角色的ASP.NET MVC 5自定义导航栏引导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是ASP.NET MVC 5内置的身份验证方法。我想根据用户是在角色显示和隐藏链路(在菜单中导航栏)。
I'm using the ASP.NET MVC 5 built in authentication methods. I would like to show and hide links (in the menu navbar) based on the role the user is in.
有没有人acheived呢?
Has anyone acheived this?
在哪里将是一个起点?
推荐答案
只是包装您的链接中:
@if (User.IsInRole("SomeRole"))
{
...
}
这篇关于基于用户角色的ASP.NET MVC 5自定义导航栏引导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!