Adding more than one role to a user after registring in asp.net

♀尐吖头ヾ 提交于 2019-12-11 08:51:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!