From 568725ce8feadf1e6976f9b765a57cce7d3dc241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E5=AE=88=E4=B8=80?= <3226562056@qq.com> Date: Sat, 28 May 2022 03:19:57 +0000 Subject: [PATCH] 1 --- ...24\347\253\240\344\275\234\344\270\232.md" | 255 ++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 "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" 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 0000000..d1ebe07 --- /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" %> + + + + + + +
+ +