I have a login form like this :
[HttpPost]
public ActionResult Login(UserAccount user , [Bind(Include = "ID,NameOfSession")] SessionSave Sessions)
{
using (QuestionsDBContext db = new QuestionsDBContext())
{
var usr = db.userAccount.Single(u => u.UserName == user.UserName && u.Password == user.Password);
if (user != null)
{
Session["UserID"] = usr.UserID.ToString();
Session["Username"] = usr.UserName.ToString();
return RedirectToAction("Index");
}
else
{
ModelState.AddModelError("", "Username or Password is wrong");
}
}
return View();
}
It appears every time I want to go to the index view, as it is coded like this. I want to make it remember all time when I log in at once. I know, I can do it by many ways, but please inform me about possible ways and any further references, that can be useful.