阅读背景:

asp.net 在线人数统计,页面访问量 Application ,session

来源:互联网 
1.新建网站,添加几个窗体。webForm1.aspx ,ViewStateForm.aspx 2.在网站的根目录下添加全局应用程序类“Global.aspx” 。(重要) 3.在“Global.aspx” 有固有的格式和会话信息结构。 4.在“Global.aspx”中各个函数中添加处理代码。详细如下: <%@ Application Language="C#" %> 5. 在webForm1.aspx 的相应的CS文件中添加如下的代码: public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { OutputUserCount(); } } protected void OutputUserCount() //显示当前站点在线人数 { Response.Write("站点在线人数:"); Response.Write(Application["UserCount"].ToString()); Response.Write(" 人。"); Response.Write("本页面的访问量:"); Response.Write(Application["StatCount"].ToString()); Response.Write(" 。"); } } 6. ViewStateForm.aspx 的相应的CS文件中添加如下的代码: public partial class ViewStateForm : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { OutputUserCount(); } } protected void OutputUserCount() //显示当前站点在线人数 { Response.Write("站点在线人数:"); Response.Write(Application["UserCount"].ToString()); Response.Write(" 人。"); Response.Write("本页面的访问量:"); Response.Write(Application["StatCount_ViewSF"].ToString()); Response.Write(" 。"); } } 7. webconfig 中也有部分对session的配置控制。 1.新建网站,添加几个窗体。webForm1.aspx ,ViewStateForm.aspx



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: