飘凌 blog


·飘凌 blog首页 · 个人主页

2008/2/25 21:18:12
dotnet web页 利用global.asax文件动态在线人数统计

     index.aspx

<%@ Page language="c#" Codebehind="4-25.aspx.cs" AutoEventWireup="false" Inherits="study._4_25" %>
<%Response.Write("现在有" + Application["whoson"] + "人在线");%>
---------------------------------------
global.asax

<%@ Application Codebehind="Global.asax.cs" Inherits="study.Global" %>
<script language="C#" runat="server">
void Session_OnStart()
{
Application.Lock();
Application["whoson"] = Convert.ToInt32 (Application["whoson"])+1;
Application.UnLock();
}

void Session_OnEnd()
{
Application.Lock();
Application["whoson"] = Convert.ToInt32 (Application["whoson"])-1;
Application.UnLock();
}

public void Application_OnStart()
{
Application.Lock();
Application["whoson"]=0;
Application.UnLock();
}
</script>
返回顶部 评论 返回首页

    大名:

    标题:
    验证码:
 

Copyright © 2008 piaoling http://www.xiang6963.cn All Rights Reserved .

 飘凌blog 管理