我是ASP.Net的新手,我有一個基本問題。我試圖找到答案,但我失敗了。ASP.Net - 會話超時後過去會發生什麼
我使用會話變量來通過我的web應用中的頁面攜帶記錄的用戶ID。
if (Session["LoggedUserKey"] == null)
{
Session.Add("LoggedUserKey", UserID);
}
else
{
Session["LoggedUserKey"] = UserID;
}
我不確定會話超時到期後會發生什麼?我會失去我的用戶ID嗎?而將是會話超時擴展時,我會問像會話變量:您的會話已過期
protected void Page_Load(object sender, EventArgs e)
{
if (Session["LoggedUserKey"] == null)
{
Response.Redirect("~/Login.aspx");
return;
}
}
一旦會話過期,您將失去LoggedUserKey中的userid值。 – Arbaaz