实现访客计数器 [英] Implementing a visitor counter

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

问题描述

我是一个新手,正在使用 ASP .Net 2.0 和 C# 2005 开发一个网站.我想添加一个工具来计算编号.我网站的访问者.我已经收集了使用 Global.asax 添加此功能的基本信息.我通过在 system.web 部分下添加行"对 Web.config 进行了修改.

I am a newbie and developing a website using ASP .Net 2.0 with C# 2005. I would like to add a facility to count the no. of visitors to my website. I have collected the basic informations to add this feature using Global.asax. I have made modifications to Web.config by adding the line "" under system.web section.

我正在使用表格来记录访问者的数量.但我不知道如何完成任务.我的默认 Global.asax 文件带有不同的部分 Application_Start、Application_End、Application_Error、Session_Start 和 Session_End.我试图在 Application_Start 部分提取计数器的当前值并存储在全局变量中.我会增加 Session_Start 中的计数器并将修改后的值写入 Application_End 中的表.

I am using a table to keep the count of visitors. But I don't know how to complete the task. My default Global.asax file came with different sections Application_Start, Application_End, Application_Error, Session_Start and Session_End. I have tried to extract the current value of the counter in the Application_Start section and store in a global variable. I would increment the counter in Session_Start and write the modified value to the table in Application_End.

我尝试使用公共子程序/函数.但是我应该把这些子程序放在哪里呢?我试图在 Global.asax 本身中添加子程序.但是现在我遇到了错误,因为我无法在 Global.asax 中添加对 Data.SqlClient 的引用,并且我需要对 SqlConnection、SqlCommand、SqlDataReader 等的引用来实现这些功能.我是否必须为每个子程序添加类文件?请指导我.

I have tried to use public subroutines/functions. But where should I place those subroutines? I tried to add the subroutines in the Global.asax itself. But now I am getting errors, as I can not add reference to Data.SqlClient in Global.asax and I need references to SqlConnection, SqlCommand, SqlDataReader etc. to implement the features. Do I have to add Class files for each subroutines? Please guide me.

我还想对我的网站实施跟踪功能,并存储我网站访问者的 IP 地址、使用的浏览器、访问日期和时间、屏幕分辨率等.我该怎么做?

I would also like to implement tracking feature to my website and store the IP address, browser used, date and time of visit, screen resolution etc of my websites visitors. How can I do it?

等待建议.

拉利特·库马尔·巴里克

Lalit Kumar Barik

推荐答案

Google 分析脚本正是您所需要的.因为会话也会为爬虫打开.

Google analytic script is exactly what you need. Because session, will opens for crawlers too.

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

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