Click here to Skip to main content
11,806,026 members (54,388 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 2: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 Richard Deeming 225
1 OriginalGriff 215
2 Sergey Alexandrovich Kryukov 170
3 ppolymorphe 125
4 Abhinav S 118
0 OriginalGriff 3,300
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web02 | 2.8.151002.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