else { context.Response.Write("{\"status\":\"请重新获取验证码,验证码失效\"}"); }
小禾斗 发表于2020-04-03 12:41
检查代码,代码位置或者对应关系写错了
//<summary>
//注册后登录
//</summary>
//<param name="context"></Param>
public void RegLogin(HttpContext context)
{
string nc = HttpContext.Current.Request.Form["nc"].ToString();
string sj = HttpContext.Current.Request.Form["sj"].ToString();
string pw1 = HttpContext.Current.Request.Form["pw1"].ToString();
string sex = HttpContext.Current.Request.Form["sex"].ToString();
//验证手机短信验证码是否正确
if (true)
{
UserBll bll = new UserBll();
UserModel m = new UserModel();
//设置模板类
m.User_hd = "Systemimg/logo.png";
m.User_Name = sj;
m.Pwd = pw1;
m.WhereCom = "9";
m.State = "0";
m.RegTime = DateTime.Now.ToString();
m.PhoneNum = sj;
m.PetName = nc;
m.sex = sex;
m.Pinfo = " ";
m.Utype = "1";
//调用后台方法进行调用
if (bll.AddUser(m))
{
HttpContext.Current.Session["username"] = sj;
HttpContext.Current.Session["UserInfo"] = m;
context.Response.Write("{\"status\":\"0\"}");
return;
}
}
else
{
context.Response.Write("{\"status\":\"手机验证码不正确\"}");
}
}
这段代码是照着书上打的,最后的else处context那里提示“检测到无法访问的代码”,是不是if(true)那里有问题