Count no of visitor
how to count total number of visitors in .net??
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Shubham SaxenaRank #278 · 8.9K reputationPosted Jul 27, 2012, 10:56 PM EDT
Hardik PatelRank #4,439 · 343 reputationPosted Jul 28, 2012, 12:17 AM EDT
rohit pzatel3 reputationPosted Jul 29, 2012, 11:14 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 29, 2012, 11:36 PM EDT
Please refer,
http://www.aspnettutorials.com/tutorials/database/hit-cntr-asp4-cs.aspx
it is good examle of hit count.
same thing you can achive writing code in Application_beginRequest event of global.aspx file.
hope this will help you.
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 29, 2012, 11:47 PM EDT
Count the total number of visitors enter to a website
Default.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Default.aspx.vb code
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim result As Integer
result = Convert.ToInt32((Application("usercount")))
Label1.Text = Convert.ToString(result)
If (result < 10) Then
Label1.Text = "000" + Label1.Text
ElseIf (result < 100) Then
Label1.Text = "00" + Label1.Text
ElseIf (result < 1000) Then
Label1.Text = "0" + Label1.Text
End If
End Sub
End Class
Global.asax code
<%@ Application Language="VB" %>
Dim count As Integer = 0
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
Application("usercount") = count
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
count = Convert.ToInt32(Application("usercount"))
Application("usercount") = count + 1
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
End Sub
Thanks
If this post helps you mark it as answer
vijay172 reputationPosted Aug 1, 2012, 3:07 AM EDT
Refer the below link to count the total vistors in .net
http://www.dotnetcode.in/2011/06/how-to-find-number-of-online.html