ASP.NET - how many people visited my page online

Asked By kiruba .e on 13-Feb-12 02:24 AM

I created a page and hosted in online.  Just i want to know, how many people visited or seen my page in online.  How to get the count of no of users on my page.   How to do this in

Pls help

dipa ahuja replied to kiruba .e on 13-Feb-12 02:40 AM
► Add a Global.asax file in your website >> Add New Item >>Global Application Class and write this code in it.
 public static int count = 0;
void Application_Start(object sender, EventArgs e)
Application["myCount"] = count;

void Session_Start(object sender, EventArgs e)
   count =
Application["myCount"] = count + 1;
Now every time when visitor open your site the variable count will be increased by one.
► To Get the total at you home page you can write it as:
int a;
a = Convert.ToInt32(Application["myCount"]);
kiruba .e replied to dipa ahuja on 13-Feb-12 02:43 AM
if i hosted in online, overall count can i find? different user will see my site from diff.system. 
dipa ahuja replied to kiruba .e on 13-Feb-12 02:57 AM
Yes this will increase the count whenever new user from any other machine visit your site
Web Star replied to kiruba .e on 13-Feb-12 03:34 AM
Better is you can use Imports System.IO and write the counter value in xml file than if your application end than also preserved previous hit count value as permanent and one more thing you can specify the page specific hit count using this method so put the code to get hit couter from that xml file in page load of that page and show it in label control simply
PrivateSub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

IfNot Page.IsPostBack Then
Dim nCount As Int32 = 0
nCount = GetCounterValue()
lblTest.Text = nCount.ToString()


PrivateFunction GetCounterValue() As Int32

Dim ctrFile As StreamReader
Dim ctrFileW As FileStream
Dim sw As StreamWriter
Dim strPath AsString = Server.MapPath("indexcount.txt")
Dim strCounterContents AsString
Dim nCounter As Int32
If (File.Exists(strPath)) Then
ctrFile = File.OpenText(strPath)
strCounterContents = ctrFile.ReadLine().ToString()
nCounter = Convert.ToInt32(strCounterContents)
nCounter = 0
nCounter += 1
ctrFileW = New FileStream(strPath, FileMode.OpenOrCreate, FileAccess.Write)
sw = New StreamWriter(ctrFileW)
Return nCounter

kalpana aparnathi replied to kiruba .e on 13-Feb-12 04:01 AM

Use or on your web server or Use a tool like Log Parser or a stat application to parse the IIS logs.

Sandeep Mittal replied to kiruba .e on 13-Feb-12 04:25 AM
Use Google Analytics. You can open google analytics account for free.
It has lot of various features and reports.
[)ia6l0 iii replied to kiruba .e on 13-Feb-12 09:10 PM
The only foolproof way to find unique visitors to your site/page - without much coding - is to use the services of third-party like Believe me, I have almost tried all ways suggested above - and none are fool-proof. 

Simplest way to integrate to their services is to drop a script that they give. 

They have a pretty good support team and can give you code samples on the reporting aspects as well. And note that with their web analytics package, you get more than the unique visitors. 

Hope this helps.