Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 注册时为用户分配角色_Asp.net_Visual Studio 2010 - Fatal编程技术网

Asp.net 注册时为用户分配角色

Asp.net 注册时为用户分配角色,asp.net,visual-studio-2010,Asp.net,Visual Studio 2010,我有一个名为“客户”的角色,我希望将自动注册的用户添加到该角色。目前,我只能使用ASP.net网站管理工具为用户分配角色。我正在使用vb web配置文件中帐户文件夹中的默认LogOn.aspx和Register.aspx文件 我看到其他用户使用了: Dim uName As String = registrationWizard.UserName.ToString Roles.AddUserToRole(uName, "Customer") 我不确定这到底应该放在哪里,或者这是否有效 谢

我有一个名为“客户”的角色,我希望将自动注册的用户添加到该角色。目前,我只能使用ASP.net网站管理工具为用户分配角色。我正在使用vb web配置文件中帐户文件夹中的默认LogOn.aspx和Register.aspx文件

我看到其他用户使用了:

Dim uName As String = registrationWizard.UserName.ToString   
Roles.AddUserToRole(uName, "Customer")
我不确定这到底应该放在哪里,或者这是否有效


谢谢您的帮助。

我在AccountController下面添加了以下代码,它成功了

Roles.AddUserToRole(model.UserName, "Customer")