you can add a line inside Session_Start: Response.Redirect("login.aspx");but this redirection happens only when the user accesses your page again. To do it automatically on the client side, you need to use some javascript, for example: <script language="javascript"> var oTimeID = null; var nTimeout = 1200000;//20 minutes var sURL = "login.aspx";function resetTimeout() { if (oTimeID != null) clearTimeout(oTimeID); oTimeID = setTimeout("window.location.href='" + sURL + "';", nTimeout); } function document.onmousemove() { resetTimeout(); }function document.onkeydown() { resetTimeout(); } function window.onload() { resetTimeout(); }</script>
you can just copy all my code into your html page or into a js file and include it into your page, but if you override any of the three functions, make sure they call resetTimeout() in your code
思归,我是如下调用你的脚本的: …… <body …… onload="window.onload()"> …… 可是现在在调用这页面的时候,会出现“Stack overflow at line:54”的错误,这是怎么一回事?
remove onload="window.onload()" from <body …… onload="window.onload()"> ===> <body>
Response.Redirect("login.aspx");but this redirection happens only when the user accesses your page again. To do it automatically on the client side, you need to use some javascript, for example: <script language="javascript">
var oTimeID = null;
var nTimeout = 1200000;//20 minutes
var sURL = "login.aspx";function resetTimeout()
{
if (oTimeID != null)
clearTimeout(oTimeID); oTimeID = setTimeout("window.location.href='" + sURL + "';", nTimeout);
}
function document.onmousemove()
{
resetTimeout();
}function document.onkeydown()
{
resetTimeout();
}
function window.onload()
{
resetTimeout();
}</script>
public void Session_End(Object sender, EventArgs e)
{
Response.Redirect("leave.aspx");
}
在web.config中session的超时时间是“10”,可是时间到了,session已经超时了,页面也没有跳转到我所指定的leave.aspx中呀
……
<body …… onload="window.onload()">
……
可是现在在调用这页面的时候,会出现“Stack overflow at line:54”的错误,这是怎么一回事?
from
<body …… onload="window.onload()">
===>
<body>