i have the following code:
if (Membership.FindUsersByName(username) == null)
{
Membership.CreateUser(username, password, email);
}
if (!Roles.RoleExists("USR"))
{
Roles.CreateRole("USR");
}
Roles.AddUserToRole(username,"USR");
Data is being inserted in the aspnet_Users and aspnet_UsersInRoles, but data is not being inserted in the aspnet_membership and i need this data as i’m using the asp login control.
can someone help me out?
The problem is with the if statement. The reason why it doesn’t work is because the FindUsersByName method returns a collection of MembershipUsers. There might not be any users, but a collection still gets returned.
Please change the statement to the following…
That should do it.