0
我正在處理ASP.NET MVC 5應用程序,並且遇到將數據存儲到會話的問題。我得到的值始終爲空。如何在ASP.NET MVC 5中設置和檢索會話?
這裏是我設置會話:
string mail = user.Email;
string response = user.CheckEmail();
Session["email"] = mail;
我在這裏測試會話,它重定向到YYY:
if ((string)Session["mail"] != null)
{
return RedirectToAction("PPP");
}
else
{
return RedirectToAction("YYY");
}
請立即幫助將不勝感激。謝謝
我只是在編碼後建立項目。無法確定原因 – Izuagbala
您使用的是什麼會話服務?你確定客戶端正在保留一個會話令牌嗎? –
[ViewData,ViewBag,Session,TempData的正確時間是什麼]的可能重複(https://stackoverflow.com/questions/12676924/what-is-the-right-time-for-viewdata-viewbag-session- tempdata) –