Click here to Skip to main content
13,087,941 members (64,793 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2017
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