User can't login after creating them with the asp.net Create User Wizard
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 CreateUser开发者_开发问答Wizard1_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");
}
I figured it out. The problem was that after I created the user, the next page would display a message saying the user was created successfully with a continue button. When I clicked continue it would take me to the login page where I would try to login with the new user, but because it would try to access the admin section when I tried to login with the new user, it would not login.
精彩评论