⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.asax.cs

📁 简易BBS源码,包括系统管理、论坛管理、用户可以看懂源码
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;

namespace RBBBS 
{
	/// <summary>
	/// Summary description for Global.
	/// </summary>
	public class Global : System.Web.HttpApplication
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		public Global()
		{
			InitializeComponent();
		}	
		
		protected void Application_Start(Object sender, EventArgs e)
		{
			Application["user_sessions"]=0;
			Application["count"]=0;

		}
 
		protected void Session_Start(Object sender, EventArgs e)
		{
			Application.Lock();
			Application["user_sessions"] = (int)Application["user_sessions"] + 1;
			//判断当前有几个人在线,然后赋值到Application["user_sessions"]变量.
			Application.UnLock();
			//数据库连接
			Session["str_connection"]=System.Configuration.ConfigurationSettings.AppSettings["Connectionstring"];


		}

		protected void Application_BeginRequest(Object sender, EventArgs e)
		{
			Application["StartTime"] = System.DateTime.Now;

		}

		protected void Application_EndRequest(Object sender, EventArgs e)
		{
			System.DateTime startTime = (System.DateTime)Application["StartTime"];
			System.DateTime endTime = System.DateTime.Now;
			System.TimeSpan ts = endTime - startTime;
			Response.Write("<table border=0' bgcolor='#ffffff'  width='100%'><tr><td height='20' align='center' width='100%'><font size=1 color='Silver'>页面执行耗时:" + ts + "秒<font></td></tr></table>");


		}

		protected void Application_AuthenticateRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_Error(Object sender, EventArgs e)
		{

		}

		protected void Session_End(Object sender, EventArgs e)
		{
			Application.Lock();
			Application["user_sessions"] = (int)Application["user_sessions"] - 1;
			//当用户离开站点的时候减1
			Application.UnLock();

		}

		protected void Application_End(Object sender, EventArgs e)
		{

		}
			
		#region Web Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.components = new System.ComponentModel.Container();
		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -