diff --git "a/28\345\256\213\345\256\210\344\270\200/0526-\347\254\254\344\272\224\347\253\240\344\275\234\344\270\232.md" "b/28\345\256\213\345\256\210\344\270\200/0526-\347\254\254\344\272\224\347\253\240\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..d1ebe0715bd494cb88d454228d776da4eaf22612 --- /dev/null +++ "b/28\345\256\213\345\256\210\344\270\200/0526-\347\254\254\344\272\224\347\253\240\344\275\234\344\270\232.md" @@ -0,0 +1,255 @@ +#### 1 + + + +```C# +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Security; +using System.Web.SessionState; + +namespace WebApplication1 +{ + public class Global : System.Web.HttpApplication + { + + protected void Application_Start(object sender, EventArgs e) + { + Application.Lock(); + Application["visitor"] = 0; + Application["online"] = 0; + Application.UnLock(); + } + + protected void Session_Start(object sender, EventArgs e) + { + Application.Lock(); + Application["visitor"] = (int)Application["visitor"] + 1; + Application["online"] = (int)Application["online"] + 1; + Application.UnLock(); + } + + protected void Application_BeginRequest(object sender, EventArgs e) + { + + } + + 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["online"] = (int)Application["online"] - 1; + Application.UnLock(); + } + + protected void Application_End(object sender, EventArgs e) + { + + } + } + +} +``` + + + +```c# +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApplication1 +{ + public partial class WebForm1 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + Response.Write($"该网站的总访问人数{Application["visitor"]},当前在线人数{Application["online"]}"); + } + } +} +``` + + + +#### 2 + + + +```asp +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %> + + + + + + +
+ +