From 91024c31c0b36658ec7974cf65ae090d783795b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=B9=98=E7=90=AA?= <2831539223@qq.com> Date: Sun, 29 May 2022 15:50:54 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E7=AC=AC=E4=BA=94?= =?UTF-8?q?=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\347\254\254\344\272\224\347\253\240/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/.keep" diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/.keep" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From f6b8a61bdd2f4417f75c5b24f1bd22b061fdcf34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=B9=98=E7=90=AA?= <2831539223@qq.com> Date: Sun, 29 May 2022 15:51:04 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\347\254\254\344\270\200\351\242\230/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/.keep" diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/.keep" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From c9ff2653b9acca944445ed91958a44923e377061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=B9=98=E7=90=AA?= <2831539223@qq.com> Date: Sun, 29 May 2022 15:51:29 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebForm1.aspx" | 19 +++++++++++++++++++ .../WebForm1.aspx.cs" | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/WebForm1.aspx" create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/WebForm1.aspx.cs" diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/WebForm1.aspx" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/WebForm1.aspx" new file mode 100644 index 0000000..a828a81 --- /dev/null +++ "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/WebForm1.aspx" @@ -0,0 +1,19 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="_220527._1.WebForm1" %> + +<%--设置网页的加载退出时间--%> +<%Session.Timeout = 1;%> + + + + + + + + + +
+
+
+
+ + diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/WebForm1.aspx.cs" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/WebForm1.aspx.cs" new file mode 100644 index 0000000..6ef1aa9 --- /dev/null +++ "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/WebForm1.aspx.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace _220527._1 +{ + public partial class WebForm1 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + Response.Write("总访问人数:" + Application["headcount"]+"
"); + Response.Write("在线人数:" + Application["PCU"]); + } + } +} \ No newline at end of file -- Gitee From edd95a0fbcd1f793d4efef4323403abd96328da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=B9=98=E7=90=AA?= <2831539223@qq.com> Date: Sun, 29 May 2022 15:51:39 +0000 Subject: [PATCH 4/6] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\347\254\254\344\272\214\351\242\230/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/.keep" diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/.keep" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From a1b512339bfd4659e8b0bea1c20ce1f0b7e26914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=B9=98=E7=90=AA?= <2831539223@qq.com> Date: Sun, 29 May 2022 15:52:09 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebForm1.aspx" | 35 ++++++++++++ .../WebForm1.aspx.cs" | 53 +++++++++++++++++++ .../WebForm2.aspx" | 17 ++++++ .../WebForm2.aspx.cs" | 28 ++++++++++ 4 files changed, 133 insertions(+) create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm1.aspx" create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm1.aspx.cs" create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm2.aspx" create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm2.aspx.cs" diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm1.aspx" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm1.aspx" new file mode 100644 index 0000000..75020d9 --- /dev/null +++ "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm1.aspx" @@ -0,0 +1,35 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="_220527._2.WebForm1" %> + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
用户名: +
密码: +
+
+
+
+ + diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm1.aspx.cs" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm1.aspx.cs" new file mode 100644 index 0000000..cc8fd55 --- /dev/null +++ "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm1.aspx.cs" @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace _220527._2 +{ + //二、利用Session对象保存用户登录时输入的用户名和登录系统的时间,在另一个窗体文件显示; + public partial class WebForm1 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + //登录按钮 + protected void Register_Click(object sender, EventArgs e) + { + //接收输入的信息 + string name = Name.Text; + string password = Password.Text; + + //对信息进行判断 + if (name == "admin") + { + if (password == "123456") + { + //使用Session变量Name存储用户名 + Session["Name"] = name; + + //使用Session变量存储密码 + Session["Password"] = password; + + //使用Seccion变量存储时间 + Session["Time"] = DateTime.Now; + + //跳转页面 + Response.Redirect("~/WebForm2.aspx"); + } + else + { + Response.Write(""); + } + } + else + { + Response.Write(""); + } + } + } +} \ No newline at end of file diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm2.aspx" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm2.aspx" new file mode 100644 index 0000000..a6bb32d --- /dev/null +++ "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm2.aspx" @@ -0,0 +1,17 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="_220527._2.WebForm2" %> + + + + + + + + + +
+
+ +
+
+ + diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm2.aspx.cs" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm2.aspx.cs" new file mode 100644 index 0000000..9a43b7f --- /dev/null +++ "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\272\214\351\242\230/WebForm2.aspx.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace _220527._2 +{ + public partial class WebForm2 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + Response.Write($"欢迎用户{Session["Name"]}登录本系统
"); + Response.Write($"你登录的时间为:{Session["Time"]}
"); + } + + //退出按钮 + protected void Quit_Click(object sender, EventArgs e) + { + //用Session.Abandon()退出当前对话 + Session.Abandon(); + + //跳转回登录页面 + Response.Redirect("~/WebForm1.aspx"); + } + } +} \ No newline at end of file -- Gitee From d467d5666a9ed9c7b235683ba86a4ea006d35d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=B9=98=E7=90=AA?= <2831539223@qq.com> Date: Sun, 29 May 2022 15:53:22 +0000 Subject: [PATCH 6/6] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global.asax" | 1 + .../Global.asax.cs" | 83 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/Global.asax" create mode 100644 "22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/Global.asax.cs" diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/Global.asax" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/Global.asax" new file mode 100644 index 0000000..9a7960e --- /dev/null +++ "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/Global.asax" @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="_220527._1.Global" Language="C#" %> diff --git "a/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/Global.asax.cs" "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/Global.asax.cs" new file mode 100644 index 0000000..49976e7 --- /dev/null +++ "b/22\350\256\270\346\271\230\347\220\252/\344\275\234\344\270\232/\347\254\254\344\272\224\347\253\240/\347\254\254\344\270\200\351\242\230/Global.asax.cs" @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Security; +using System.Web.SessionState; + +namespace _220527._1 +{ + //一、利用Application实现网站在线人数和总访问人数的统计功能 + public class Global : System.Web.HttpApplication + { + //程序请求开始 + protected void Application_Start(object sender, EventArgs e) + { + //Application.Lock():锁定Application对象,有数字运算都要用 + Application.Lock(); + + //定义Application["headcount"]总人数 + Application["headcount"] = 0; + + //定义在线人数 + Application["PCU"] = 0; + + //Application.UnLock():解锁Application对象,有数字运算都要用 + Application.UnLock(); + } + + //用户第一次登录 + protected void Session_Start(object sender, EventArgs e) + { + //Response.Write("用户登录
"); + + Application.Lock(); + + //总访问人数 + Application["headcount"] = (int)Application["headcount"] + 1; + + //在线人数 + Application["PCU"] = (int)Application["PCU"] + 1; + + Application.UnLock(); + } + + //页面请求开始触发 + protected void Application_BeginRequest(object sender, EventArgs e) + { + //Response.Write("页面开始
"); + + + + } + + protected void Application_AuthenticateRequest(object sender, EventArgs e) + { + Response.Write("页面加载
"); + } + + //页面请求结束 + protected void Application_Error(object sender, EventArgs e) + { + Response.Write("页面结束
"); + } + + //用户退出 + protected void Session_End(object sender, EventArgs e) + { + //Response.Write("用户退出
"); + + Application.Lock(); + //在线用户退出后 + Application["PCU"] = (int)Application["PCU"] - 1; + + Application.UnLock(); + } + + //程序请求结束 + protected void Application_End(object sender, EventArgs e) + { + Response.Write("程序关闭
"); + } + } +} \ No newline at end of file -- Gitee