Click here to Skip to main content
12,302,376 members (63,819 online)
Rate this:
 
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 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160530.1 | Last Updated 5 Nov 2011
Copyright © CodeProject, 1999-2016
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