计数网站上的访客数量不起作用? [英] Counting number of visitors on website not working ?

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

问题描述

大家好,

我正在尝试获取网站的访问者人数.这就是iam在做的事情:

Hi all ,

I am trying to get the number of visitors of my website.And this is what iam doing:

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
      ' Fires when the application is started
      ' da.Update(0, 1)
      count = da.Select_visitors_count
      Application("myCount") = count
  End Sub

  Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
      ' Fires when the session is started

      Application("myCount") = count + 1
      da.Update(Application("myCount"), 1)
  End Sub


因此,我将使用类型化数据集的访问者数量计入计数并增加值.但是问题是它被增加了20次,又增加了10次,又增加了14.倍.... S怎么了?

知道在本地主机上很棒.

谢谢.


So iam getting the count of visitors using typed dataset into the count and incrementing the value.But the problem is that it is being incremented once by 20 and another time by 10 and another time by 14....S what is wrong ?

Knowing that on local host it is great.

Thanks.

推荐答案

为什么不简单地编写一个存储过程以增加计数器(可能设置一个日期列以指示上次更新的日期时间) ,然后留在那儿?

届时,您可以随时检索它,并且您将知道截至保存的日期时间有多少用户访问了您的网站.
Why don''t you simply write a stored proc that increments the counter (and maybe sets a date column to indicate the datetime of the last update), and leave it at that?

At that point, you can retrieve it any time you want and you''ll know how many users have accessed your site as of the saved datetime.


void Application_Start(object sender, EventArgs e)
 {
        int num=1; //for the first visitor
        Application["VisitorCount"]= num;
 }



void Session_Start(object sender, EventArgs e)
{
        int num = Int32.Parse(Application["VisitorCount"].ToString());
        num++;
        Application["VisitorCount"] = num;
}


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

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