How to show the total visitors of website ? [Resolved]

Posted by Munder2013 under ASP.NET on 5/13/2013 | Points: 10 | Views : 3891 | Status : [Member] | Replies : 10
Plz tell me
how to count the no. of hits on my website?
and
how to check online visitors ?

Thanks & Regards
Baljeet Singh



Responses

Posted by: Satyapriyanayak on: 5/13/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
Default.aspx code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
<asp:Label ID="Label2" Text="Total no of Visitors" runat="server" BackColor="#FFFFCC" ForeColor="#663300"></asp:Label>
<asp:Label ID="Label1" runat="server" Text="Label" BackColor="#66FFFF"
ForeColor="#FF3300"></asp:Label>
</form>
</body>
</html>

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" %>

<script runat="server">
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

</script>


If this post helps you mark it as answer
Thanks

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 5/14/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
here is your solution just check out the below link
http://www.dotnetfunda.com/codes/code3973-dispaly-number-of-online-user-on-webpage.aspx

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Munder2013 on: 5/13/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Satyapriyanayak,

Thank you sir... Plz tell me also how to check online members ?

Thanks & Regards
Baljeet Singh

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 5/13/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Refer

http://www.c-sharpcorner.com/UploadFile/munnamax/whoseonline08042007062609AM/whoseonline.aspx
http://blog.dreamlabsolutions.com/post/2009/07/13/ASPNET-Membership-Show-list-of-users-online.aspx
http://www.codeproject.com/Questions/491558/Howplustoplusseepluswhoplusisplusonlineplusinplusa


If this post helps you mark it as answer
Thanks

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Munder2013 on: 5/13/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks alot sir

Thanks & Regards
Baljeet Singh

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Munder2013 on: 5/14/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks Ankit
It is more easy to understand... thanks a lot

Thanks & Regards
Baljeet Singh

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 5/14/2013 [Member] Starter | Points: 25

Up
0
Down
thanks baljeet :)

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Munder2013 on: 5/15/2013 [Member] Starter | Points: 25

Up
0
Down
you are welcome Ankit

Thanks & Regards
Baljeet Singh

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 5/20/2013 [Member] Starter | Points: 25

Up
0
Down
http://www.aspnetcodes.com/2011/05/count-every-visitor-on-page-through-use.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Munder2013 on: 5/21/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks for sharing link

Thanks & Regards
Baljeet Singh

Munder2013, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response