Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
how we can count the no. of hits on website using vb.net
Posted 4-Nov-11 20:02pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

One of the popular way to do this is using "Google Analytics".
 
http://www.google.com/analytics/
 
http://en.wikipedia.org/wiki/Google_Analytics
 
Edit (Spelling Corrected) - However I would not prefer VB.Net(code-behind) logic for this when you can achieve this using simple Javascript(Google Analytics).
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Do following code in Global.asax
 
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
 
'This variable Hits will store the # of visitors

Application("hit") = 0
 
End Sub
 
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
 
'Lock the Application for concurrency issues

Application.Lock()
 
'Increment the counter

Application("hit") = Application("hit") + 1
 
'Unlock the Application

Application.UnLock()
 
End Sub
 

on any page you can get application hits using application("Hits")
 
session starts event called when user visit the site and couter gets increased by 1
  Permalink  
Comments
purnananda behera at 5-Nov-11 2:43am
   
This is nice but manually have to add the Global.asax or by default it is there.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Write this code to your global.asax
 
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
Application("counter") = Application("counter") + 1
Application.UnLock()
End Sub
and write these lines in your default homepage
 
<%
Application.Lock()
Application("counter") = CType(Application("counter") + 1, Int32)
Application.UnLock()
%>
Everything will be fine then.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 550
1 mhegazy94 460
2 Ravi Bhavnani 230
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,295
1 OriginalGriff 6,841
2 CPallini 5,420
3 George Jonsson 3,654
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 5 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100