如何显示当前查看我网站的访客总数 [英] how I can display a count of the total number of visitors currently viewing my website

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

问题描述



我想显示当前正在查看我网站的访客数量。如果你知道请帮助我。

Hi,
I want to display the number of Visitors currently viewing my website. If you know please help me on it.

推荐答案

参考这个

http://stackoverflow.com/questions/1508529/count-number-of-visitors-in-网站使用asp-net-and-c-sharp [ ^ ]


参考这些类似的主题

如何显示访客总数到我的网站? [ ^ ]

我怎么算数当前登录我网站的会话数(用户)? [ ^ ]

显示访问我们的网络应用程序的访问者数量 [ ^ ]

访问该网站的访客数量 [ ^ ]
Refer these similar threads
How to show the total number of visitors to my website?[^]
how can i count number of session(user) currently logged in in my website ?[^]
display Number of visiters visited our webapplication[^]
Count of visitors visiting the website[^]


在项目中添加一个Global.asax文件,添加新项目菜单。 />


在Global.asax中处理以下事件。



Add a Global.asax file in your project from add new item menu.

In Global.asax handle the following events.

void Application_Start(object sender, EventArgs e)
    {
        Application["myCount"] = count;
        
    }










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

    }







以及要显示计数的页面的页面加载



添加以下代码。






and in the page load of the page where you want to display the count

add the following code.

a = Convert.ToInt32((Application["myCount"]));
          Label1.Text = Convert.ToString(a);







标签会显示计数



请记住,如果您重置IIS,计数将被重置。



因此更好地存储它在数据库中并从后端获取数据并为每个会话创建增加,然后将其保存到数据库中。




the label will display the count

Remember if you reset the IIS the count will be reset.

So better to store it in database and get the data from backend and increment for every session creation and then save it in to database.


这篇关于如何显示当前查看我网站的访客总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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