在session_end()从定向。
session有一定时间。用户长时间没有操作页面的话会发生session_end()
在重新指向到我的首页。

解决方案 »

  1.   

    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>
      

  2.   

    我在global.asax中照此添加:
    public void Session_End(Object sender, EventArgs e)
    {
    Response.Redirect("leave.aspx");
    }
    在web.config中session的超时时间是“10”,可是时间到了,session已经超时了,页面也没有跳转到我所指定的leave.aspx中呀
      

  3.   

    思归,你的javascript脚本在页面中该如何调用呢???麻烦您给个完整的实现代码吧
      

  4.   

    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
      

  5.   

    思归,我是如下调用你的脚本的:
    ……
    <body  …… onload="window.onload()">
    ……
    可是现在在调用这页面的时候,会出现“Stack overflow at line:54”的错误,这是怎么一回事?
      

  6.   

    remove onload="window.onload()"
    from
    <body  …… onload="window.onload()">
    ===>
    <body>