3

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?

BattlFrog
  • 3,370
  • 8
  • 56
  • 86
  • 1
    Darin - Actuallu I have found the majority of MVC to be quite straight forward. I started about a year ago and really enjoy it. But Simple(yeah, right)Membership and Membership in general has proven to be, borderline incomprehensible. I was about to just write my own, then it suddenly started working. By Magic. – BattlFrog May 09 '13 at 21:14

1 Answers1

4

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

System.Web.Security.Roles.AddUsersToRole("user1", "user2", "user3", ... , "yourrolename");
Kenneth
  • 28,294
  • 6
  • 61
  • 84
  • Thanks Ken, I will try that. Actually I will use AddUserToRole, so when someone signs up, they get assigned a role. – BattlFrog May 09 '13 at 21:15