< script runat = " server " > void Application_Start( object sender,EventArgs e) { // 在应用程序启动时运行的 System.Data.sqlClient.sqlConnection con = DBConnect.createConnection(); con.open(); System.Data.sqlClient.sqlCommand com = new System.Data.sqlClient.sqlCommand( " select * from total " ,con); int count = System.Convert.ToInt32(com.ExecuteScalar()); con.Close(); Application[ " total " ] = count; Application[ " online " ] = 0 ; } void Application_End( object sender,EventArgs e) { // 在应用程序关闭时运行的代码 System.Data.sqlClient.sqlConnection con = DBConnect.createConnection(); con.open(); System.Data.sqlClient.sqlCommand com = new System.Data.sqlClient.sqlCommand( " update total set num= " + Application[ " total " ].ToString(),con); com.ExecuteNonQuery(); con.Close(); } void Application_Error( object sender,EventArgs e) { // 在出现未处理的错误时运行的代码 } void Session_Start( object sender,EventArgs e) { // 在新会话启动时运行的代码 Session.Timeout = 1 ; Application.Lock(); Application[ " total " ] = System.Convert.ToInt32(Application[ " total " ]) + 1 ; Application[ " online " ] = System.Convert.ToInt32(Application[ " online " ]) + 1 ; Application.UnLock(); } void Session_End( object sender,EventArgs e) { // 在会话结束时运行的代码。 // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer // 或 sqlServer,则不会引发该事件。 Application.Lock(); Application[ " online " ] = System.Convert.ToInt32(Application[ " online " ]) - 1 ; Application.UnLock(); } </ script >
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。