Search code examples
asp.net-mvc-4simplemembership

SimpleRole / SimpleMember - add user to role


MVC4 using SimpleMembership & Role.

So after 18 hours of research, googling, trial & error, etc I finally have simpleMembership working. However, after multiple step-throughs and different scenarios, I cant find where the new user is assigned to a role. I have roles in my webpages_Roles table.

So, does one of the 4000 built-in methods do the assigning and I just need to add it somewhere? Or do I need to do it manually?


Solution

  • You can add a user to a role with the following code:

    System.Web.Security.Roles.AddUsersToRole("user1", "user2", "user3", ... , "yourrolename");