Login method:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login([Bind(Include = "Id,Mail,Pass")] LoginMember member)
{
if (!(ModelState.IsValidField("Mail") && ModelState.IsValidField("Pass")))
{
return View(login);
}
var areThere = db.LoginMember.Any(x => x.Mail == member.Mail && x.Sifre == member.Sifre);
if (areThere)
{
var name = db.LoginMember.Where(x => x.Id == member.Id).Select(x => x.Name);
Session["login"] = name;
return RedirectToAction("Index", "Index");
}
}
This method is running, session is creating "Session["login"] = name;" and going to "return RedirectToAction("Index", "Index");".
Index view:
@{
Layout = null;
}
@Session["login"]
<html>Index</html>
When Index view is running, has an error that is "System.ObjectDisposedException: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.", what is the wrong?