This is just the "most simplified" guide for my students who wish to use the Membership class in their small school project.
// create
var status = new MembershipCreateStatus();
Membership.CreateUser(txtUserName.Text, txtPassword.Text, txtEmail.Text, txtQuestion.Text, txtAnswer.Text, true, out status);
//update
MembershipUser user = Membership.GetUser(); user.ChangePasswordQuestionAndAnswer(txtPassword.Text, txtQuestion.Text, txtAnswer.Text);
Membership.UpdateUser(user);
//delete
MembershipUser user = Membership.GetUser();
Membership.DeleteUser(user.UserName);
Your next assignment?
Improve the procs in creating and assigning roles. Sample:
Roles.CreateRole("Admin");
Roles.AddUserToRole(txtName.Text, "Admin");
Roles.GetRolesForUser("Harold");
No comments:
Post a Comment