一段时间不活动或会话到期后,将用户重定向到登录页面. [英] Redirect the user to login page after a period of inactivity or when the session expires.

查看:170
本文介绍了一段时间不活动或会话到期后,将用户重定向到登录页面.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间不活动或会话到期后,将用户重定向到登录页面.

Redirect the user to login page after a period of inactivity or when the session expires.

推荐答案

您好,
通常,您可以设置会话超时,还可以添加页面标题,以自动将当前页面重定向到您在会话超时之前清除会话的页面.

来自 http://aspalliance.com/1621_Implementing_a_Session_Timeout_Page_in_ASPNET.2 [
Hi,
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.

From 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应该链接到一个页面,您可以在其中清除会话和任何其他用户数据.

当刷新头过期时,它将自动将其重定向到该页面.

此处 [ http://csharpdotnetfreak.blogspot.com/2008/11/detecting-session- timeout-and-redirect.html [ ^ ]
http://forums.asp.net/p/1299988/2533830.aspx [ ^ ]



--Amit



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.

Here[^] is a video, you must watch that.

Also check the following:
http://csharpdotnetfreak.blogspot.com/2008/11/detecting-session-timeout-and-redirect.html[^]
http://forums.asp.net/p/1299988/2533830.aspx[^]



--Amit


尝试一下...

Try This...

check session on evry page and add in Web.config above the page tag.

<sessionstate timeout="5" mode="InProc"></sessionstate>


it redirect to homepage when user is idle for 5 minutes.


if any query ,please post it.


重定向到会话页面 [ ^ ]
重定向到- login-page-on-session-expiration-asp-net [
Is Google[^] broken at your place? It returned about 225,000 results (0.42 seconds) for your query.
Top Results:

redirect-to-login-page-on-session[^]
redirect-to-login-page-on-session-expiration-asp-net[^]


这篇关于一段时间不活动或会话到期后,将用户重定向到登录页面.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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