问题描述
我要做的是,我已经使用Global.asax.cs文件中的函数来检测用户的登录会话何时到期,如果该会话已到期,则应将用户重定向到登录页面,代码如下所示:
protected void Session_Start(object sender,EventArgs e)
{
if (Context.Session != null)
{
if (Session.IsNewSession)
{
HttpCookie newSessionIdCookie = Request.Cookies["ASP.NET_SessionId"];
if (newSessionIdCookie != null)
{
string newSessionIdCookieValue = newSessionIdCookie.Value;
if (newSessionIdCookieValue != string.Empty)
{
//I want to let the client side page to pop-up an alert to indicate the user
//that the session is expired.
Response.Write("<script>alert('Your Session is out,please re-login!');</script>");
// This means Session was timed Out and New Session was started
Response.Redirect("Login.aspx");
}
}
}
}
}
但是,我当前代码的问题是,会话期满后,页面将直接重定向,根本没有弹出警报。
有人可以帮忙吗?预先感谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)