会话超时后刷新时自动重定向到登录页面 [英] Automatic redirection to login page while refreshing after session timout
问题描述
你好朋友,
在我的应用程序webconfig中,我将以下代码添加到会话timout中,并重定向到登录页面,此处登录页面为Default.aspx,但无法正常工作,您能知道原因吗?
< authentication mode ="forms">
< forms LoginUrl =〜/Default.aspx" timeout = 1></forms>
在此先感谢
Hello friends,
in My application webconfig i put the below code to session timout and redirection to login page here login page is Default.aspx but it is not working can u know the reasons please help me
<authentication mode="forms">
<forms LoginUrl="~/Default.aspx" timeout=1></forms>
thanks in advance
推荐答案
第一个链接与您要执行的操作类似;
您可以设置会话超时,还可以添加页面标题,以自动将当前页面重定向到您在会话超时之前清除会话的页面.
在ASPNET中实现会话超时页面 [构建一个ASP.NET会话超时重定向控制. [会话超时后将用户重定向到登录页面 [
The first link is similar to what you are trying to do;
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.
Implementing a Session Timeout Page in ASPNET[^]
For other options;
You can build an ASP.NET session timeout redirect control.[^]
Redirecting User to Login Page After Session Timeouts[^]
or
you can use javascript;
<script language='javascript'>
function SessionTimeOuts()
{
self.setTimeout("RedirectToLogin();", 'any time period you wish to put here');
}
function RedirectToLogin()
{
alert('Your session has expired.');
window.location.href = 'login.aspx'
//any page where you want the redirection
}
</script>
<BODY onload=SessionTimeOuts()'>
如果使用母版页,请将脚本放置到母版页.如果不是,请为此脚本创建一个单独的文件,然后将该脚本链接到所有页面.
祝你好运.
If you are using master page place the script to master page. If you are not then create a seperate file for this script and link that script to all pages.
Good luck.
这篇关于会话超时后刷新时自动重定向到登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!