【发布时间】:2011-04-27 12:13:49
【问题描述】:
如果会话已空闲 5 分钟,我想在登录页面上显示“您的会话已过期”。
Sql Session State 和 Form Authentication Time Out 的超时值应该是多少:
- 一样吗?
- 会话状态>表单超时
- 表单超时 > 会话时间。
理想情况下,如果有人能解释上述之间的差异,我们将不胜感激。
目前,我的代码如下所示,即使在登录重定向空闲 5 分钟后 Session["SessionID"] 也不是 Null:
On Session_Start()
Session["SessionID"] = Guid.NewGuid();
在 LogOn.cshtml 上:
@{
string sessionExpiredMsg = string.Empty;
HttpContext ctx = HttpContext.Current;
if (ctx.Session["SessionID"] == null)
{
sessionExpiredMsg = "Your session has expired. Please re-login again.";
}
}
@
在 web.config 上:
<sessionState
timeout=5....
<authentication mode="forms"
timeout=5....
谢谢。
【问题讨论】:
标签: asp.net