public ActionResult Login(string ID_PENGGUNA, string KAD_PENGENALAN) { var membershipHelper = new MemberShipHelper(); var model = new UserModel(); // try //{ if (Membership.ValidateUser(ID_PENGGUNA, KAD_PENGENALAN)) { model.ID_PENGGUNA = ID_PENGGUNA; model.KAD_PENGENALAN = KAD_PENGENALAN; FormsAuthentication.SetAuthCookie(model.ID_PENGGUNA, false); Session["LoginUser"] = membershipHelper.GetUserProfile(model.ID_PENGGUNA, model.KAD_PENGENALAN); return(RedirectToAction("Index", "Home")); } else { TempData["Msg"] = "Invalid User Name and Password!"; return(RedirectToAction("Login")); } //} //catch (Exception e) //{ // TempData["Msg"] = e.Message; // return RedirectToAction("Login"); // } }
public ActionResult Login(UserModel model) { var membershipHelper = new MemberShipHelper(); try { if (Membership.ValidateUser(model.Email, model.Password)) { FormsAuthentication.SetAuthCookie(model.Email, false); Session["LoginUser"] = membershipHelper.GetUserProfile(model.Email, model.Password); return(RedirectToAction("Index", "Home")); } else { TempData["Msg"] = "Invalid User Name and Password!"; return(RedirectToAction("Login")); } } catch (Exception e) { TempData["Msg"] = e.Message; return(RedirectToAction("Login")); } }