How to enable multiple roles for a MVCsitemapNode-ASP.NET
I am using MVCsiteMapNode
to display the menu for various roles.
For single role Iam using the following.
<mvcSiteMapNode title="NewMenuItem" controller="TestMenu"
action="Index" Roles="SystemAdmin"/>
For Multiple Roles, I want to display the same menu. It tried this:
<mvcSiteMapNode title="NewMenuItem" controller="TestMenu"
action="Index" Roles="SystemAdmin开发者_开发问答,NewRole"/>
It does not display if the current user is a member of the SystemAdmin role.
In my helper class I am using the following
if (isSystemAdmin)
{
if (node["roles"].Equals("SystemAdmin"))
{
DisplayMenu(sb, node);
}
}
Can anybody help? Thank you.
Try something like:
if (node["roles"].Contains("SystemAdmin")) ...
精彩评论