在相关的ASPX页面,增加
<% Session.Abandon() %>

解决方案 »

  1.   

    服务器session 超时不触发这个事件吗?
      

  2.   

    超时应该会触发,但在ASP.NET里时常不触发,不知是不是MS的bug示例代码
    try (not always work, since the user can go to another site):<script language=javascript>
    function window.onunload()
    {
            if (event.clientX < 0 && event.clientY < 0)
                  window.open("logout.aspx", "logout");
    }
    </script>in logout.aspx:
    <% Session.Abandon() %>
      

  3.   

    session_end会有延迟,默认为20分钟,因为服务器端并不知道客户端是否已经关闭了浏览器,只能根据超过延迟时间未有浏览动作来判断他的SESSION已经END。
      

  4.   

    to hychieftain(不同): 可是我把 session timeout 设置为2分钟, 然后我等了几个小时也不会执行呀!
      

  5.   

    Session timeout 不定很经常!所以一般用Session.Abandon
      

  6.   

    我用了Session.Abandon啊,但是session_end有时候会执行,有时候又不会,不知道是不是iis的问题。
      

  7.   

    First of all, Session_End event is supported only in InProc mode. In order for Session_End to be fired, your session state has to exist first. That means you have to store some data in the session state and has completed at least one request.