会话过期后转到登录页面 [英] Go to Login Page when session expires

查看:89
本文介绍了会话过期后转到登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道如何在会话结束后编写一些会自动打开登录页面的代码吗?


-
Ad****@hotmail.com

Hi all,
I was wondering how i could write some code which would automatically open
the Login Page once the session has expired?

--
Ad****@hotmail.com

推荐答案

您可以使用setTimeout javascript函数。


< script language =" javascript">

//这将在20分钟后调用javascript方法_SessionExpired


setTimeout(" _SessionExpired()",20 * 60 * 1000);


函数_SessionExpired()

{

location.href =" login.aspx" ;;

}

< / script>

从打开页面开始经过20分钟后,浏览器将被重定向到登录页面

。由于您要重定向

用户,您可能需要在19分钟时向他们发出警告

即将到期。


HTH,


账单


" ACaunter" <广告**** @ hotmail.com>在留言中写道

新闻:2C ********************************** @ microsof t.com ...
You can use the setTimeout javascript function for this.

<script language="javascript">
//this will call the javascript method _SessionExpired after 20 minutes

setTimeout( "_SessionExpired()", 20 * 60 * 1000 );

function _SessionExpired()
{
location.href = "login.aspx";
}
</script>

When 20 minutes has elapsed from the page opening the browser will be
redirected to the login page. Since you are going to be redirecting the
user you might want to give them a warning at say 19 minutes their session
is about to expire.

HTH,

bill

"ACaunter" <Ad****@hotmail.com> wrote in message
news:2C**********************************@microsof t.com...
大家好,
我想知道如何编写一些代码,这些代码会在会话过期后自动打开登录页面?

-
Ad****@hotmail.com



您还可以在Global.asax中添加以下内容:


protected void Session_End(Object sender,EventArgs e)

{

Response.Redirect(" login.aspx");

}

You can also put the following in Global.asax:

protected void Session_End(Object sender, EventArgs e)
{
Response.Redirect( "login.aspx" );
}


既不提供,也不提供其他解决方案。


当会话结束/到期时,服务器无法知道用户是否知道用户是否知道用户已离开网站

,目前已有10个网站。


Juan T. Llibre

ASP。 NET MVP

===========

" Stefan Kiryazov" < CH *** @ bulgaria.com>在消息中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ...
Neither that, nor the other solutions offered, will work.

When a session ends/expires, the server has no way
of knowing whether the user has already left the site
and is currently 10 sites away.


Juan T. Llibre
ASP.NET MVP
===========
"Stefan Kiryazov" <ch***@bulgaria.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
您还可以将以下内容放在Global.asax中:

protected void Session_End(Object sender,EventArgs e)
{
Response.Redirect(" login。 aspx);
}
You can also put the following in Global.asax:

protected void Session_End(Object sender, EventArgs e)
{
Response.Redirect( "login.aspx" );
}



这篇关于会话过期后转到登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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