ASP.NET推重定向会话超时 [英] ASP.NET Push Redirect on Session Timeout

查看:215
本文介绍了ASP.NET推重定向会话超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一个教程,博客条目,或在技术上有所帮助网站背后当会话期满时,自动将用户(即没有回发)。任何帮助AP preciated

I'm looking for a tutorial, blog entry, or some help on the technique behind websites that automatically push users (ie without a postback) when the session expires. Any help is appreciated

推荐答案

通常,设置会话超时,并且您还可以添加页面头部为当前页面自动跳转到你之前清除会话右页会话超时。

Usually, you set the session timeout, and you can additionally add a page header to automatically redirect the current page to a page where you clear the session right before the session timeout.

从<一个href=\"http://aspalliance.com/1621_Implementing_a_Session_Timeout_Page_in_ASPNET.2\">http://aspalliance.com/1621_Implementing_a_Session_Timeout_Page_in_ASPNET.2

namespace SessionExpirePage
{
    public partial class Secure : System.Web.UI.MasterPage
    {
        public int SessionLengthMinutes
        {
            get { return Session.Timeout; }
        }
        public string SessionExpireDestinationUrl
        {
            get { return "/SessionExpired.aspx"; }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            this.PageHead.Controls.Add(new LiteralControl(
                String.Format("<meta http-equiv='refresh' content='{0};url={1}'>", 
                SessionLengthMinutes*60, SessionExpireDestinationUrl)));
        }
    }
}

该SessionExpireDestinationUrl应该链接到您清除会话和任何其他用户数据的页面。

The SessionExpireDestinationUrl should link to a page where you clear the session and any other user data.

在刷新到期头,它会自动重定向到该页面。

When the refresh header expires, it will automatically redirect them to that page.

这篇关于ASP.NET推重定向会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆