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

来源:互联网 发布:java远程调用技术 编辑:程序博客网 时间:2024/05/23 01:16
1.新建网站,添加几个窗体。webForm1.aspx ,ViewStateForm.aspx2.在网站的根目录下添加全局应用程序类“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的配置控制。然后就可以在IIS中进行测试了。这个处理方法在IIS重启后就会重新从零进行统计。本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/eqiang8271/archive/2007/10/23/1838742.aspx
原创粉丝点击