忽略@ Html.Action()如果用户不在角色 [英] Ignore @Html.Action() if user not in Role
问题描述
在我的查看我渲染菜单 @ Html.Action(RenderMenu,管理)
和 @ Html.Action(RenderMenu,经理)
其中action:
[授权(角色=管理员)]
公众的ActionResult RenderMenu()
{
返回查看();
}
块引用>如果用户没有在角色的管理
@ Html.Action(RenderMenu,管理)
忽略。
块引用>我该怎么办呢?
现在,我有无限的登录窗口。解决方案请参阅我的回答
<一href=\"http://stackoverflow.com/questions/20303162/asp-net-mvc3-is-really-based-on-roles-html-action/20303267#20303267\">Asp.net MVC3:真的是基于角色@ Html.Action()您可以用得到它:
@ Html.ActionBaseRole(RenderMenu,管理)
In my View i render menu
@Html.Action("RenderMenu", "Admin")
and@Html.Action("RenderMenu", "Manager")
Where Action:[Authorize(Roles = "Admin")] public ActionResult RenderMenu() { return View(); }
If user not in Role Admin
@Html.Action("RenderMenu", "Admin")
just ignore.how can I do it? Now, i have infinite login window.
解决方案See my answer Asp.net MVC3: is really based on roles @Html.Action()
you can get it using:
@Html.ActionBaseRole("RenderMenu", "Admin")
这篇关于忽略@ Html.Action()如果用户不在角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!