在ASP.NET中获取准确的总访问者数量的问题 [英] problem with get the accurate total visitors count in ASP.NET

查看:74
本文介绍了在ASP.NET中获取准确的总访问者数量的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我使用此代码获取访问我网站的用户的计数器

Hi all
I used this codes for get counter of users who visted my site

<%@ Application Language="C#" %>

<script runat="server">

    public static int totalNumberOfUsers = 0;
    public static int currentNumberOfUsers = 0;
    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        Application["totalNumberOfUsers"] = 0;
        Application["currentNumberOfUsers"] = 0;
    }
    
    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started
        Application.Lock();
        Application["totalNumberOfUsers"] = ((int)Application["totalNumberOfUsers"] + 1);
        Application["currentNumberOfUsers"] = ((int)Application["currentNumberOfUsers"] + 1);
        Application.UnLock();

    }

    void Session_End(object sender, EventArgs e) 
    {
        Application.Lock();
        Application["currentNumberOfUsers"] = ((int)Application["currentNumberOfUsers"] - 1);
        Application.UnLock();
    }
       
</script>





但如果在没有请求网站任何页面的情况下过了20分钟,那么计数器goback到0 ??为什么??



请帮帮我

问候



But If 20 minutes elapsed without requested any page from website, then the counter goback to 0 ?? why ??

please help me
regards

推荐答案

用于数据处理你将得出结果。

如果你得到ip地址和Store In数据库u将是特定用户明智的访问者数量的最佳方式。

OR

每次和每次打开您的网站时插入或更新数据库中的查询使用和U获取Perfact结果。
Use in databing u will perfact result.
If U get ip address and Store In database u will best way to specific user wise visiter count.
OR
Each and Every time open your web site insert or update Query use in Database and U get Perfact Result.


这篇关于在ASP.NET中获取准确的总访问者数量的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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