现在的位置: 首页 > 综合 > 正文

ASP.net(C#)如何添加Global.asax,在Global.asax.cs中控制session超时的跳转。

2013年08月16日 ⁄ 综合 ⁄ 共 356字 ⁄ 字号 评论关闭

添加Global.asax。

http://www.webkaka.com/tutorial/asp.net/2012/06208/

在Session_End方法中代码:

  protected void Session_End(object sender, EventArgs e)
        {    // 在会话结束时运行的代码。 
            // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 InProc 时,才会引发 Session_End 事件。
            // 如果会话模式设置为 StateServer 
            // 或 SQLServer,则不会引发该事件。
        
                    Response.Write("<script>alert('您还没有登陆或者登陆已超时');parent.window.location.href='Login.aspx'</script>");
                

        }

抱歉!评论已关闭.