ASP.NET MVC在线人数统计

在Global.asax.cs文件中代码:

ASP.NET MVC在线人数统计
protected void Application_Start()
{
    Application["OnLineUserCount"] = 0;
    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);
}

protected void Session_Start(object sender, EventArgs e)
{
    Application.Lock();
    Application["OnLineUserCount"] = Convert.ToInt32(Application["OnLineUserCount"]) + 1;
    Application.UnLock();
}

protected void Session_End(object sender, EventArgs e)
{
    Application.Lock();
    Application["OnLineUserCount"] = Convert.ToInt32(Application["OnLineUserCount"]) - 1;
    Application.UnLock();
}
ASP.NET MVC在线人数统计

ASP.NET MVC在线人数统计,布布扣,bubuko.com

ASP.NET MVC在线人数统计

上一篇:SQL Server基础


下一篇:mongodb文档支持的数据类型