C#的统计问题,高手进!
来源:百度知道 编辑:UC知道 时间:2024/07/05 19:26:00
是asp.net 把。。那需要用 session对象。。。是对话级的对象。
下面是代码。。自己可以根据情况改改。。。
这个是写在全局里的。。就是这个文件:global.asax
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
Application["total"] = 0;
Application["online"] = 0;
}
void Application_End(object sender, EventArgs e)
{
// 在应用程序关闭时运行的代码
}
void Application_Error(object sender, EventArgs e)
{
// 在出现未处理的错误时运行的代码
}
void Session_Start(object sender, EventArgs e)
{
// 在新会话启动时运行的代码
Session.Timeout = 1;
Application.Lock();//防止并发,进行加锁
Application["total"] = (int)Application["total"]+1;
Application["online&q