Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how we can count the no. of hits on website using vb.net
Posted

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).
 
Share this answer
 
v3
Do following code in Global.asax

VB
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
 
Share this answer
 
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.
 
Share this answer
 
Write this code to your global.asax

VB
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.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900