User can't login after creating them with the asp.net Create User Wizard

Posted by Xaisoft on Stack Overflow See other posts from Stack Overflow or by Xaisoft
Published on 2009-10-21T19:54:30Z Indexed on 2010/05/17 2:10 UTC
Read the original article Hit count: 364

When I create a user, they can't login until I go into the asp.net configuration and save them. I actually don't change any settings, I just press the save button and then they can login in. What I would like to do is to have the user be able to login once they are created, but I can't seem to get it to work. Here is my code for the CreatedUser method:

 protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
 {
     CustomerProfile adminProfile = CustomerProfile.GetProfile();
     string username = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName")).Text.Trim();

        CustomerProfile createdUser = CustomerProfile.GetProfile(username);
        createdUser.CustomerID = adminProfile.CustomerID;

        createdUser.Save();

        MembershipUser user = Membership.GetUser(username);

        user.IsApproved = ((CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("chkActivateUser")).Checked;

        Roles.AddUserToRole(user.UserName, "nonadmin");

    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET