keywan salimi
keywan salimi

Reputation: 17

What is the reason if Roles.AddUserToRole(..) does not work?

I implemented membership in asp.net, I have a manager that can define users, users have USER role, when I use below code to assign role, it does not work:

Roles.AddUserToRole(txtUsername.Text, "USER");

Now my question is: What is the reasons?

when I log in and check its roles, there is no role. I use this code for detect role:

string[] role = Roles.GetRolesForUser(txtUserName.Text);

Upvotes: 0

Views: 1803

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94643

From MSDN doc:

  1. Role management is not enabled. -or- User is already assigned to the specified role.
  2. roleName is an empty string or contains a comma (,). -or- username is an empty string or contains a comma (,).
  3. roleName is null. -or- username is null.

Upvotes: 3

Related Questions