Roles.AddUserToRole gives an error " The user 'newUser' is already in role 'Guests' "

When using a standard login control it won't allow me to add a new user, not even "JoeBloggs".
The following is the code:
Roles.AddUserToRole(username, "Guests")

The following is the error:
An exception of type 'System.Configuration.Provider.ProviderException' occurred in System.Web.dll but was not handled in user code
Additional information: The user 'JoeBloggs' is already in role 'Guests'.
LVL 1
Netlink2Asked:
Who is Participating?
 
Ajay SharmaCommented:
0
 
RedKelvinCommented:
0
 
Netlink2Author Commented:
What I did to fix the problem was to delete the login database, recreate it with aspnet_regsql.exe. Then I redid the actual login page from scratch.

I also had to change the web.config file to
  <remove name="LocalSqlServer"/>
  <add name="LocalSqlServer" connectionString="Data Source=Server;Initial Catalog=RealEstate;Persist Security Info=True;User ID=myId;pwd=myPW"/>

I still don't know exactly where the problem was, but removing the connectionstring caused the error to change.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.