Global.asax.cs之在线人数统计
1 protected void Application_Start() 2 { 3 Application["OnLineUserCount"] = 0; 4 AreaRegistration.RegisterAllAreas(); 5 6 RegisterGlobalFilters(GlobalFilters.Filters); 7 RegisterRoutes(RouteTable.Routes); 8 } 9 10 protected void Session_Start(object sender, EventArgs e) 11 { 12 Application.Lock(); 13 Application["OnLineUserCount"] = Convert.ToInt32(Application["OnLineUserCount"]) + 1; 14 Application.UnLock(); 15 } 16 17 protected void Session_End(object sender, EventArgs e) 18 { 19 Application.Lock(); 20 Application["OnLineUserCount"] = Convert.ToInt32(Application["OnLineUserCount"]) - 1; 21 Application.UnLock(); 22 }