访问该网站的访客数量 [英] Count of visitors visiting the website

查看:87
本文介绍了访问该网站的访客数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不进行数据库交互的情况下获取访问该网站的访问者数量

How to get the count of visitors visiting the website,without having database interaction

推荐答案

您可以使用global.asax文件,例如



u can use global.asax file for that like

void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        Application["Users"]=0;

    }




void Session_Start(object sender, EventArgs e)
  {
      // Code that runs when a new session is started
      Session["suer"] =Convert.ToInt32( Application["Users"])+ 1;
      Application["Users"] = Session["suer"];
  }





然后页面加载





then on page load

Response.Write(Session["suer"].ToString());


在此尝试: http://www.tinycounter.com/ [ ^ ]


在这里查看:

http://www.aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx [ ^ ]



global.asax 文件中编写代码,与整个应用程序进行交互。

示例代码如下:

Look here:
http://www.aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx[^]

Write code in global.asax file which interacts with the entire application.
The sample code is given below:
void Application_OnStart(Object Sender, EventArgs E)
        {
            Application["CurrentUsers"] = 0;
        }
        void Session_OnStart(object Sender, EventArgs E)
        {
            Application.Lock();
            Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
            Application.UnLock();
        }
        void Session_OnEnd(object Sender, EventArgs E)
        {
            Application.Lock();
            Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
            Application.UnLock();
        }


这篇关于访问该网站的访客数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆