Hi ,
I want know how to find how many members visit my website and overall members visited my website in asp.net 2.0?
please help me my problem.I am always starting global.aspx coding
public static double count = 1000.0;
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["OnlineUsers"] = count;
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Session["username"] = "";
Session["etype"] = "";
Application.Lock();
count = Convert.ToInt32(Application["OnlineUsers"]);
Application["OnlineUsers"] = count+ 1;
}
//Which page i want display visitors
protected void Page_Load(object sender, EventArgs e)
{
Application.Lock();
if (Application["HitCount"] != null)
{
Application["HitCount"] = (int)Application["HitCount"] + 1;
}
else
{
Application["HitCount"] = 1000;
}
Application.UnLock();
visitor.Value = Application["HitCount"].ToString();
}
But this coding using daily visitors only.But i want overall visitors in my website.
Please help me.
Loading
Anuja PawarPosted Dec 2, 2011, 4:47 AM
sankarPosted Dec 2, 2011, 4:43 AM
Anuja PawarPosted Dec 1, 2011, 9:18 AM
<%@ Application Language="C#" %>
and on page load
protected void Page_Load(object sender, EventArgs e)
{
int a; a = Convert.ToInt32(Application["myCount"]); Label4.Text = a.ToString("0000");
}
Satyapriya NayakPosted Dec 1, 2011, 2:43 AM
Try this...
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