Pergunta

I am using asp.net 4.5 membership provider and roles,

problem is I'm trying to set up the creat user wizard to make the new member a certain role strait out the box. this is the code I am using.

Code

 protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
    Roles.AddUsersToRole(CreateUserWizard1.UserName,"customer");
}

}

and the error log is giving me a error that I can not convert string and a best overload match, is there a easy way around this?

I just need to make it that all new users are customer.

Thank You

Foi útil?

Solução

I believe the first parameter in the AddUsersToRole is a string array, hence the name of the method "Users", so try something like this:

string[] usersToAdd = new string[] { CreateUserWizard1.UserName };

Roles.AddUsersToRole(usersToAdd,"customer");

HTH

Phil

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top