【问题标题】:how to show the message for session expired in asp.net using httpcontext如何使用httpcontext在asp.net中显示会话过期的消息
【发布时间】:2012-08-25 03:15:23
【问题描述】:

在会话超时后将用户重定向到登录页面类似于在一定间隔后刷新页面的方法。唯一不同的是计算页面必须重定向的时间。因此,可以使用 Session.timeout 属性计算时间,该属性将为我们提供该会话的会话超时值。为该值添加一些宽限时间,并自动将用户重定向到登录页面。

【问题讨论】:

    标签: asp.net session


    【解决方案1】:

    protected void Page_Init(object sender, EventArgs e) { 检查会话(); }

    private void CheckSession()
    {
        if (Session["SessionID"] == null)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "var r = confirm('Your Session Has Expired'); if (r == true) var str= 'PartnerLogin.aspx'; location.href = str ;", true);
    
        }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-28
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 2021-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多