会话结束后,用C#代码制作一个简单的JavaScript Alert弹出窗口

问题描述

要做的是,我已经使用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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...