0

I have a role called 'Customer', I wish to add users who register automatically to that role. At the moment I can only assign users to roles by using ASP.net Web Site Administration Tool. I'm using the default LogOn.aspx and Register.aspx files from Account folder in vb web profile.

I have seen that other users have used:

Dim uName As String = registrationWizard.UserName.ToString   
Roles.AddUserToRole(uName, "Customer")

I'm not sure exactly where this needs to go, or even if this would work?

Thanks for any help.

4

1 回答 1

0

我在 AccountController 下方添加了以下代码,并且它有效。

Roles.AddUserToRole(model.UserName, "Customer")
于 2013-03-12T15:59:25.233 回答