0

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("");
    }

1 Answer 1

1

In your view, you should be able to perform a check on your User property:

@if(User.IsInRole("supervisor"))
{
//Markup here...
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.