Click here to Skip to main content
16,017,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
visitors count in asp.net without in process mode like text file,xml file,database.
Posted

1 solution

Go to Global.asax page and add the following code

C#
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["NoOfVisitors"] = 0;
}

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application.Lock();
Application["NoOfVisitors"] = (int)Application["NoOfVisitors"] + 1;
Application.UnLock();
}


Now open your aspx page and write the following code
XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1"runat="server">
<table>
<tr>
<td>
<b>No of Visits:</b>
</td>
<td>
<asp:Label ID="lblCount" runat="server" ForeColor="Red" />
</td>
</tr>
</table>
</form>
</body>
</html>


Now open your cs file and add the following code
C#
protected void Page_Load(object sender, EventArgs e)
{
lblCount.Text = Application["NoOfVisitors"].ToString();
}



Refer
http://www.aspdotnet-suresh.com/2013/11/asp-net-count-number-of-visitors-in-Website.html[^]
 
Share this answer
 
v3
Comments
Vijay M 23-May-14 1:35am    
The Count will be losed when server has restated.without losing the count how to do.thanks for your help

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