public ActionResult Login(string Username, string Password) { var f_password = FunctionUtils.MD5(Password); var user = _db.KhachHangs.Where(x => x.TenDangNhap.Equals(Username) && x.MatKhau.Equals(f_password)).ToList(); if (user.Count() > 0) { Session["UserName"] = user.SingleOrDefault().TenDangNhap; // return RedirectToAction("/Home/Index"); return(new RedirectResult("/Home/Index")); } else { ViewBag.error = "Tài khoản hoặc mật khẩu sai!"; //return new RedirectResult("/Account/Login"); return(RedirectToAction("/Account/Login")); } }
public ActionResult Login(string username, string password) { if (ModelState.IsValid) { var f_password = FunctionUtils.MD5(password); var user = _db.USERS.Where(x => x.UserName.Equals(username) && x.PassWord.Equals(f_password)).ToList(); if (user.Count() > 0) { Session["userid"] = user.SingleOrDefault().UserId; Session["UserName"] = user.SingleOrDefault().UserName; Session["Avatar"] = user.SingleOrDefault().Avatar; return(RedirectToAction("Index")); } else { ViewBag.error = "Tài khoản hoặc mật khẩu sai!"; return(new RedirectResult("/Administrator/Home/Login")); } } return(View("Index")); }