【发布时间】:2012-10-17 13:39:01
【问题描述】:
可能重复:
How to Check whether Session is Expired or not in asp.net
页面在后面的代码中检测会话是否超时的最佳方法是什么? 我在博客 (http://mattslay.com/detecting-session-timeout-in-asp-net/) 中找到了以下代码。没问题还是有更好的方法?
if (Context.Session != null && Context.Session.IsNewSession)
{
string cookieHeader = Page.Request.Headers["Cookie"];
if ((null != cookieHeader) && (cookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
return true; // timeout occured
else
return false;
}
【问题讨论】:
标签: asp.net