default.aspx 页面代码:
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
    <script type="text/ecmascript" language="javaScript">
        function removeline()
        {
            if(event.clientX<0 && event.clientY<0)
            {
                 alert("我进入了removeline方法啦,说明捕捉有效!");
                 document.write('<iframe width="100" height="100" src="LoginOut.aspx"></iframe><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>');
                 document.all.WebBrowser.ExecWB(45,1);
            }
        }
    </script>
</head>
<body onunload="removeline();">
    <form id="form1" runat="server">
    <div>
        当前在线人数:<% =Application["userCount"].ToString() %>
        <br />
        <asp:LinkButton ID="loginOut" runat="server" Text="LoginOut" onclick="loginOut_Click"></asp:LinkButton>
    </div>
    </form>
</body>
</html>default.aspx.cs 页面代码:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {    }
    protected void loginOut_Click(object sender, EventArgs e)
    {
        Server.Execute("LoginOut.aspx");
        Response.Write("<script type='text/javascript'>window.opener=null;window.close();</script>");
    }
}Global.asax  页面代码:
<%@ Application Language="C#" %><script runat="server">    void Application_Start(object sender, EventArgs e) 
    {
        //在应用程序启动时运行的代码
        Application["userCount"] = 0;
    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //在应用程序关闭时运行的代码    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        //在出现未处理的错误时运行的代码    }    void Session_Start(object sender, EventArgs e) 
    {
        //在新会话启动时运行的代码
        Application.Lock();
        Application["userCount"] = (int)Application["userCount"] + 1;
        Application.UnLock();
    }    void Session_End(object sender, EventArgs e) 
    {
        //在会话结束时运行的代码。 
        // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
        // InProc 时,才会引发 Session_End 事件。如果会话模式 
        //设置为 StateServer 或 SQLServer,则不会引发该事件。
        Application.Lock();
        Application["userCount"] = (int)Application["userCount"] - 1;
        Application.UnLock();
    }
       
</script>
loginout。aspx 页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginOut.aspx.cs" Inherits="LoginOut" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>
loginout。aspx。cs 页面
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class LoginOut : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session.Clear();
        Session.Abandon();
    }
}
我是这样写的,但是根本就捕捉不到关闭浏览器时的动作啊?怎么改呢?