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

Posted on 2007-10-15
Last Modified: 2012-05-05
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'.
Question by:Netlink2
    LVL 22

    Assisted Solution

    LVL 18

    Accepted Solution

    LVL 1

    Author Comment

    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.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now