我有一个登录页面,我在登录时重定向到另一个页面 . 我在Session中保存了一些数据,但无法在Page2.aspx中检索相同的数据 .
我发现一些博客和网站说明了同样的问题,但他们的解决方案不起作用 .
这是我的Page1.aspx代码
会话[“用户名”] =名称;的Response.Redirect( “〜/ Page2.aspx”,假);
在Page2.aspx中
protected void Page_Load(object sender,EventArgs e){if(Session [“Username”]!= null)
ClientScript.RegisterStartupScript(GetType(),“”,“sendtoken();”,true);
其他
的Response.Redirect( “Page1.aspx的”);
}
Session [“Username”]为空
n web.config中的代码很简单 . 我试过用
sessionState timeout =“2”
ñ
mode =“InProc”和“StateServer”
2 回答
最常见的原因是cookie被禁用 . 您需要使用cookie,或切换到无cookie会话模型,这有点难以使用 . 参考这个
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q316112
旧的,但我有类似的问题 . 确保您的iis中没有使用Web园设置 . 换句话说,检查您的应用程序池是否包含多个工作进程(这是默认值) .
应用程序池 - >高级设置 - >最大工作进程