in global.asax:
i given this code

public static int count = 0; 
    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        Application["myCount"] = count;
    }
     void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started
        //count = Convert.ToInt32(Application["myCount"]);
        count = Convert.ToInt32(Application["myCount"]);
        Application["myCount"] = count + 1;
    }

in aspx page i given this thing

protected void Page_Load(object sender, EventArgs e)
    {
        Application.Lock();
        if(Application["HitCount"]!=null)
         {
            Application["HitCount"]=(int)Application["HitCount"]+1;
         }
        else
         {
             Application["HitCount"] =1;
         }
         Application.UnLock();
        lblInfo.Text="The page has been accessed ("+Application["HitCount"].ToString()+") times";

but the problem here is it is counting up to certain time that means up to 1hr and again incrementing starts from 1 whats the problem and help me to overcome this one.

in global.asax:
i given this code

public static int count = 0; 
    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        Application["myCount"] = count;
    }
     void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started
        //count = Convert.ToInt32(Application["myCount"]);
        count = Convert.ToInt32(Application["myCount"]);
        Application["myCount"] = count + 1;
    }

in aspx page i given this thing

protected void Page_Load(object sender, EventArgs e)
    {
        Application.Lock();
        if(Application["HitCount"]!=null)
         {
            Application["HitCount"]=(int)Application["HitCount"]+1;
         }
        else
         {
             Application["HitCount"] =1;
         }
         Application.UnLock();
        lblInfo.Text="The page has been accessed ("+Application["HitCount"].ToString()+") times";

but the problem here is it is counting up to certain time that means up to 1hr and again incrementing starts from 1 whats the problem and help me to overcome this one.

:-O
Everything that you store in Application object is kept in memory until the application is closed by the last user connected.

sorry i cant get u r answer will you pls eloborate it.?
i am not that much expert in this topic pls eloborate the answer sir..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.