Nizam Nizam

Nizam Nizam

  • NA
  • 11
  • 4.5k

how to use Session in MVC4

Aug 29 2015 6:00 AM
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(Login login)
{
if (ModelState.IsValid)
{
var loginOrigin =
db.Logins.FirstOrDefault(s => s.UserName == login.UserName && s.Password == login.Password);
if (loginOrigin != null)
{
SessionValues.Current.Login = new LoginInSession
{
LoginId = loginOrigin.LoginId,
Password = loginOrigin.Password,
UserName = loginOrigin.UserName,
};
return RedirectToAction("CreateDocuments", "Home");
}
//ViewBag.message = "Invalid Username Or Password";
//return View("Login");
}
//ModelState.Clear();
return RedirectToAction("Login");
//return View();
}

Answers (5)