急急急,请各位高手救救, 我做了一个后台。想要追踪管理员 登录 退出的时间,登录简单,退出的时间怎么追踪,这个退出可能又不正常退出(直接关闭浏览器,或者 结束任务管理器) 急急急急  求大虾们给点方法

解决方案 »

  1.   

    你知道浏览器有个关闭事件吗?如果知道的话,好办了。关闭事件触发另外一个页面A,在另外一个页面后台程序里写时间,到数据库里。然后关闭A页面。<script type="text/javascript">
        window.onunload = function ()//.onbeforeunload
        {        
            window.showModalDialog("WebCloseEvent.aspx?" + new Date(), "", "dialogWidth=0px;dialogHeight=0px;");
        }
        
        </script>
    using System;
    using Cement.Business;
    using Woody.ToolSet;public partial class WebCloseEvent : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BusinessUser.Instance.ClearLoginUser();
            JSHelp.Close();
        }
    }
      

  2.   


     public static void Close()
            {
                System.Web.UI.Page currentPage = HttpContext.Current.Handler as Page;
                if (currentPage == null) return;            var s = string.Format("window.close();");
                currentPage.ClientScript.RegisterStartupScript(currentPage.GetType(), ran.Next().ToString(), s, true);
            }