Add following code in your webconfig file
<authentication mode="Forms">
<forms loginUrl="default.aspx">
</forms>
</authentication>
<membership defaultProvider="defaultMembershipProvider">
<providers>
<add name="defaultMembershipProvider" connectionStringName="ConnectionStringNmae" applicationName="ss" type="System.Web.Security.SqlMembershipProvider" requiresQuestionAndAnswer="true" passwordFormat="Clear" enablePasswordRetrieval="true" enablePasswordReset="true" minRequiredNonalphanumericCharacters="0" maxInvalidPasswordAttempts="999" passwordAttemptWindow="60" minRequiredPasswordLength="7"/>
</providers>
</membership>
<roleManager enabled="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" connectionStringName="ConnectionStringNmae" applicationName="/TESTProject" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
Then
execute your regsql.exe and define your db .The Membership table automatically create.
In your user creation page , add following code when submit your details.
if (Page.IsValid)
{
MembershipCreateStatus UserCreateStatus;
MembershipUser uu = Membership.CreateUser(txtUserName.Text , txtPassword.Text, txtUserName.Text + "@test.com", "1", "1", true, out UserCreateStatus);
switch (UserCreateStatus)
{
case MembershipCreateStatus.Success:
Object[] _Obj = new Object[] { 0, 1, 2, 3, 4 };
if (Roles.RoleExists(ddUserGroup.SelectedItem.ToString() + "_" + Session["CompanyID"].ToString()))
{
Roles.AddUserToRole(txtUserName.Text , ddUserGroup.SelectedItem.ToString() );
try
{
txtName.Text = "";
txtPassword.Text = "";
ddUserGroup.SelectedValue = "0";
lblError.Text = "";
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "<script>alert('User created successfully!');</script>", false);
}
catch
{
Membership.DeleteUser(txtUserName.Text );
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "<script>alert('User unable to create!');</script>", false);
}
}
else
{
lblError.Text = "Invalid Type Name.";
}
break;
case MembershipCreateStatus.DuplicateUserName:
lblError.Text = "";
lblError.Text = "Username already exists. Please enter a different user name.";
break;
case MembershipCreateStatus.DuplicateEmail:
lblError.Text = "";
lblError.Text = "A username for that e-mail address already exists. Please enter a different e-mail address.";
break;
case MembershipCreateStatus.InvalidPassword:
lblError.Text = "";
lblError.Text = "The password provided is invalid. Please enter a valid password value. The Password Length Min 7 character";
break;
case MembershipCreateStatus.InvalidEmail:
lblError.Text = "";
lblError.Text = "The e-mail address provided is invalid. Please check the value and try again.";
break;
case MembershipCreateStatus.InvalidUserName:
lblError.Text = "";
lblError.Text = "The user name provided is invalid. Please check the value and try again.";
break;
default:
lblError.Text = "";
lblError.Text = "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
break;
}
}