[英]Session Variable Lost?
在登錄屏幕上,我將登錄的名稱存儲在Session變量中。 但是,當按下按鈕打開新頁面時,Session變量的值在我的生產環境中丟失了,但是在測試/調試時,它仍然可以正常工作。
為什么值不能在生產中准確記錄?
protected void btnGo_Click(object sender, EventArgs e)
{
if (this.txtname.Text > 0)
{
Session["name"] = this.txtname.Text;
Response.Redirect("Page2.aspx");
}
}
//This is my page load event for page 2
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Session["name"].ToString());
}
編輯
我的webconfig文件中沒有提到任何條目
<sessionState>
編輯#2
我將此行添加到我的webconfig文件中,並且在生產中會話變量信息仍然不顯示。
<sessionState mode="InProc" cookieless="true" timeout="80" />
會話的值由於重定向操作而丟失。 您可以在此處閱讀更多示例。
使用Response.Redirect("Page2.aspx", false);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.