Click here to Skip to main content
11,494,174 members (60,838 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
Hi all
I used this codes for get counter of users who visted my site
<%@ Application Language="C#" %>
<script runat="server">
    public static int totalNumberOfUsers = 0;
    public static int currentNumberOfUsers = 0;
    void Application_Start(object sender, EventArgs e) 
        // Code that runs on application startup
        Application["totalNumberOfUsers"] = 0;
        Application["currentNumberOfUsers"] = 0;
    void Session_Start(object sender, EventArgs e) 
        // Code that runs when a new session is started
        Application["totalNumberOfUsers"] = ((int)Application["totalNumberOfUsers"] + 1);
        Application["currentNumberOfUsers"] = ((int)Application["currentNumberOfUsers"] + 1);
    void Session_End(object sender, EventArgs e) 
        Application["currentNumberOfUsers"] = ((int)Application["currentNumberOfUsers"] - 1);

But If 20 minutes elapsed without requested any page from website, then the counter goback to 0 ?? why ??

please help me
Posted 28-Mar-13 3:00am
ryanb31 at 28-Mar-13 8:06am
First off, Session_End may only end after it times out so it is not an accurate way of counting users. Secondly, your app pool is probably set to reset after 20 minutes of idle time.
ocean99 at 28-Mar-13 8:08am
"Secondly, your app pool is probably set to reset after 20 minutes of idle time."

How can me modify this time??

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Use in databing u will perfact result.
If U get ip address and Store In database u will best way to specific user wise visiter count.
Each and Every time open your web site insert or update Query use in Database and U get Perfact Result.
ocean99 at 28-Mar-13 8:12am
This is good idea,thank you, But now I want to use first method, any help please ?

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 448
1 OriginalGriff 275
2 Nakul Chaudhari 240
3 CHill60 185
4 CPallini 175
0 Sergey Alexandrovich Kryukov 10,277
1 OriginalGriff 8,805
2 Sascha Lefèvre 3,704
3 Maciej Los 3,392
4 Richard Deeming 2,500

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100