我正在制作一个 Web 项目并在此应用程序中维护角色管理。创建 Web 项目后,我在此应用程序中定义了角色管理。createUser()
当我使用函数数据存储创建用户时,我创建的aspnet_Users
其他aspnet_Membership
表(tbl_users)
存储了所有用户信息,包括aspnet_Users
表的一些信息aspnet_Membership
。我可以同时在这些表中创建数据,但现在我想同时更新和删除这些表中的数据,请问怎么可能??..让我知道。
这是我的代码
protected void btn_signup_Click(object sender, EventArgs e)
{
try
{
// Create new user.
objuser.email=txt_email.Text;
objuser.password=txt_password.Text;
objuser.username = TextBox1.Text;
if (Membership.RequiresQuestionAndAnswer)
{
MembershipUser newUser =
Membership.CreateUser(objuser.email,objuser.password,
objuser.username);
}
else
{
MembershipUser newUser = Membership.CreateUser(
objuser.email,
objuser.password,
objuser.username);
int i = BusinessUser.BusinessRegisterUser(objuser);
if (i > 0)
{
Session["user_authenticate"] = "Verified";
Session["user_email"] = objuser.email;
Label1.Text = Session["user_email"].ToString();
login1.Style.Add("display", "none");
logout.Visible = true;
Response.Redirect("user_registration.aspx");
}
}
show_menu();
//Response.Redirect("login.aspx");
}
catch (MembershipCreateUserException ex)
{
WarningModal.Show();
lblWarning.Text = GetErrorMessage(ex.StatusCode);
pnlIssues.Visible = true;
}
catch (HttpException ex)
{
WarningModal.Show();
lblWarning.Text= ex.Message;
}
}
protected void loginUser_Authenticate(object sender, AuthenticateEventArgs e)
{
try
{
if (Membership.ValidateUser(loginUser.UserName, loginUser.Password))
{
Session["user_authenticate"] = "Verified";
e.Authenticated = true;
Session["user_email"] = loginUser.UserName;
objuser.email = Session["user_email"].ToString();
Label1.Text = Session["user_email"].ToString();
login1.Style.Add("display", "none");
logout.Visible = true;
}
else
{
e.Authenticated = false;
}
}
catch (Exception ex)
{
}
}