Reputation: 109
I want to render different content in the View for each user. what is the proper way to do that in Asp.net mbc4.
I'm looking for something similar to securing views in Spring security :
<sec:authorize access="hasRole('supervisor')">
This content will only be visible to users who have
the "supervisor" authority in their list of <tt>GrantedAuthority</tt>s.
</sec:authorize>
till now I can only secure the access to controllers:
[Authorize(Roles = "supervisor")]
public ActionResult Index()
{
return View("");
}
Upvotes: 0
Views: 51
Reputation: 2840
In your view, you should be able to perform a check on your User
property:
@if(User.IsInRole("supervisor"))
{
//Markup here...
}
Upvotes: 1