请帮助我,通过创建用户向导自动将新用户分配给客户角色 [英] please help me, automatic assign new user to customer role from create user wizard

查看:81
本文介绍了请帮助我,通过创建用户向导自动将新用户分配给客户角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的感到困惑,我想在新用户注册为客户角色后自动添加新用户
我找到了要添加的代码行,但是在我的项目中找不到.我不知道为什么
这是我找到的代码.

i really confuse, i want to add the new users automatically after they signing up to customer role
i found a line of code to add but i can''t find it in my project. i don''t know why
here the code that i found.

Roles.AddUserToRole(CreateUserWizard1.UserName, "Customer");



但是,当我开始编写createuserwizard时,没有CreateUserWizard1,因此我使用以下代码:



but when i start writing the createuserwizard, there are no CreateUserWizard1, so i use this:

Roles.AddUserToRole((sender as CreateUserWizard).UserName, "Customer");



但这就是问题所在,它不起作用,用户可以注册,但未分配给客户角色.请任何人都可以帮助我.

抱歉,我的英语还不够好.
谢谢..



but that''s the problem, it doesn''t work, the user can sign up, but not assigned to customer role. please anyone can help me.

sory my english is not good enough.
thanks..

推荐答案

要将新创建的用户分配给角色,请使用以下代码:

To assign the newly created user to a role you use the following code:

Roles.AddUserToRole("username", "rolename");



根据创建用户的方式,您必须找到新用户的用户名并将其传递给上述方法.
不要忘记先创建角色.
祝你好运



Depending on how you create the user you must find the username of the newly user and just pass it into the above method.
Don''t forget to create the role first.
Good luck


这篇关于请帮助我,通过创建用户向导自动将新用户分配给客户角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆