public ActionResult DoRegister() { string email=Request["email"]; string nick = Request["nickName"]; string password = Request["password"]; string gendar = Request["gendar"]; User user = new User(); user.Email = email; user.NickName = nick; user.Password = password; user.Gendar = short.Parse(gendar); user.ProvinceID = 0; user.CityID = 0; user.DistrictID = 0; AccountManager accountManager = new AccountManager(); accountManager.LocalRegisterUser(user); User currentUser=accountManager.Login(user.Email,user.Password); if (currentUser != null) { Session["User"] = currentUser; } else { return Redirect("/Home/Index"); } return RedirectToAction("Index"); }
public ActionResult DoLogin() { string email = Request["email"]; string password = Request["password"]; string url = Request["returnURL"]; if (string.IsNullOrEmpty(email)) { return RedirectToAction("Login", new { message="邮箱地址不能为空"}); } if (string.IsNullOrEmpty(password)) { return RedirectToAction("Login", new { message = "密码不能为空" }); } AccountManager accountManager = new AccountManager(); User user = null; try { user = accountManager.Login(email, password); } catch (Exception ex) { return RedirectToAction("Login", new { message = ex.Message }); } Session["User"] = user; if (!string.IsNullOrEmpty(url)) { return Redirect(HttpUtility.HtmlDecode(url)); } return Redirect("/Home/Index"); }