一.手机号登录点击事件
if (Page.IsValid)
{
var result = AccountManager.LoginByUserName(txtMobileNumber.Text, txtPassword.Text);
if (result.StatusCode == Common.StatusCode.Succeed)
{
var user = result.ReadResult();
IdentityManager.SaveUser(user);
var url = Request.QueryString["ReturnUrl"];
if (!string.IsNullOrWhiteSpace(url))
{
Response.Redirect(url);
}
else
{
Response.Redirect("Default.aspx");
}
}
else
{
//Response.Write()
ClientScript.RegisterStartupScript(GetType(), "loginerror", $"alert('{result.Message}')", true);
}
}
二.用户名密码登录点击事件
if (Page.IsValid)
{
var result = AccountManager.LoginByUserName(txtMobileNumber.Text, txtPassword.Text);
if (result.StatusCode == Common.StatusCode.Succeed)
{
var user = result.ReadResult();
IdentityManager.SaveUser(user);
var url = Request.QueryString["ReturnUrl"];
if (!string.IsNullOrWhiteSpace(url))
{
Response.Redirect(url);
}
else
{
Response.Redirect("Default.aspx");
}
}
else
{
//Response.Write()
ClientScript.RegisterStartupScript(GetType(), "loginerror", $"alert('{result.Message}')", true);
}
}