问题
in my web site, i have three roles(Editor , Reviewer and Author) In some situations I need to add my user all 3 roles by coding. how can i do that? an also how can i update my user roles? thank you very much please guide me.
MembershipUser user = Membership.CreateUser(email, "123456",email);
Roles.AddUserToRole(email, "Editor");
回答1:
To add user to multiple roles use Roles.AddUserToRoles like this
Roles.AddUserToRoles(email, new string[] {"Editor", "Reviewer", "Author" });
I do not know about a method that updates an existing role. But you can always delete a role and add a new role instead.
来源:https://stackoverflow.com/questions/13441083/adding-more-than-one-role-to-a-user-after-registring-in-asp-net