Search code examples
asp.net-mvc-2roleproviderrights

ASP.NET MVC, One Role for two user, and little different behavior for each user


We have implemented custom roleprovider. This provide us to restricts access to parts of our site using roles. Now we have situation when two users have role Administrator. But one user1 can add comments, and user2 can not add comments(user1 and user2 have role Administrator).


What the best way to solve this problem?

Can we add roles like it Administrator.AddComment and put it in controller action?


Solution

  • How about using a Commentors role:

    [HttpPost]
    [Authorize(Roles = "Commentors")]
    public ActionResult Create(Comment comment) 
    { 
        ...
    }