4
这是我除了EndSession.aspx检查是否会话超时
override protected void OnInit(EventArgs e) {
base.OnInit(e);
if (Context.Session != null)
{
//check the IsNewSession value, this will tell us if the session has been reset.
//IsNewSession will also let us know if the users session has timed out
if (Session.IsNewSession)
{
//now we know it's a new session, so we check to see if a cookie is present
string cookie = Request.Headers["Cookie"];
//now we determine if there is a cookie does it contains what we're looking for
if ((null != cookie) && (cookie.IndexOf("ASP.NET_SessionId") >= 0))//&& !Request.QueryString["timeout"].ToString().Equals("yes"))
{
//since it's a new session but a ASP.Net cookie exist we know
//the session has expired so we need to redirect them
Response.Redirect("EndSession.aspx?timeout=yes");
}
}
}
}
但在EndSession所有网页我尝试导航回到基类,说的Default.aspx,然后这上面的代码只是重定向回到EndSession.aspx。
因此,对于更好地澄清: 第1步:进入mypage.aspx 第2步:等待超时 第3步:尝试导航离开 第4步:重定向到EndSession.aspx 步骤5:尝试导航远 第6步:设置转到4
SETP 6应该是真正能够浏览了......
(如果需要pelase要求进一步澄清)
任何想法?
谢谢!!!
你实际上在努力达到什么,你无法做到,让我们说FormsAuthentication?我的意思是你将重定向到default.aspx的原因是什么,应该发生什么魔术? – Jeroen 2010-08-06 15:33:00
我接受其他想法。虽然我应该提到我并不担心对用户进行身份验证。还有其他事情存储在会话状态中,如果他们未被特意删除可能会导致问题。我愿意接受更好的替代品,但我仍然认为我正在努力做的事情应该是可以实现的。不是吗? – kralco626 2010-08-06 17:46:32