我正在尝试在会话中存储登录用户的信息。但是,它似乎在我的应用程序中不起作用。我不断收到错误消息“当前上下文中不存在名称'Session'”
[HttpPost]
public ActionResult userLogin(User user)
{
using (TheDbContext db = new TheDbContext())
{
var usr = db.userAccount.Single(u => u.Email == user.Email && u.Password == user.Password);
if (usr != null)
{
Session["UserID"] = usr.ID.ToString();
Session["Email"] = usr.Email.ToString();
return RedirectToAction("LoggedIn");
}
}
return View();
}