locked
HitCounter Does't work RRS feed

  • Question

  • User-254743730 posted

    Hi 

    i develop one hit counter.Its working when i run the website in visual studio. the same site i ll run in iis. what last hit increased in visual studio that hits only showing. hit does't increase.

    can you please find what a problem in that.

    Wednesday, May 9, 2012 4:55 AM

Answers

  • User-8475372 posted

    I won't use global aspx page.  Home page  page load ( ) event. i get the client ip and store it on db and get retive on hits from db and  display.

    Use this :

     In Global.asax
    <script runat="server">

    public static int count = 0;
    void Application_Start(object sender, EventArgs e)
    {
    Application["myCount"] = count;
    }

    void Session_Start(object sender, EventArgs e)
    {
    count = Convert.ToInt32(Application["myCount"]);
    Application["myCount"] = count + 1;
    }

    </script>

    aspx page
    protected void Page_Load(object sender, EventArgs e)
    {
    int a;
    a = Convert.ToInt32((Application["myCount"]));
    Label4.Text = Convert.ToString(a);
    if (a < 10)
    Label4.Text = "000" + Label4.Text ;
    else if(a<100)
    Label4.Text = "00" + Label4.Text;
    else if(a<1000)
    Label4.Text = "0" + Label4.Text;
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 9, 2012 5:52 AM

All replies

  • User1730632263 posted

    In which event you are tracking hits?

    Assuming that is in Global.asax's session start event.

    Is the site precompiled before adding global.asax? Try compiling it again with Global.asax.

    Wednesday, May 9, 2012 5:11 AM
  • User-254743730 posted

    I won't use global aspx page.  Home page  page load ( ) event. i get the client ip and store it on db and get retive on hits from db and  display.

    Wednesday, May 9, 2012 5:21 AM
  • User-8475372 posted

    I won't use global aspx page.  Home page  page load ( ) event. i get the client ip and store it on db and get retive on hits from db and  display.

    Use this :

     In Global.asax
    <script runat="server">

    public static int count = 0;
    void Application_Start(object sender, EventArgs e)
    {
    Application["myCount"] = count;
    }

    void Session_Start(object sender, EventArgs e)
    {
    count = Convert.ToInt32(Application["myCount"]);
    Application["myCount"] = count + 1;
    }

    </script>

    aspx page
    protected void Page_Load(object sender, EventArgs e)
    {
    int a;
    a = Convert.ToInt32((Application["myCount"]));
    Label4.Text = Convert.ToString(a);
    if (a < 10)
    Label4.Text = "000" + Label4.Text ;
    else if(a<100)
    Label4.Text = "00" + Label4.Text;
    else if(a<1000)
    Label4.Text = "0" + Label4.Text;
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 9, 2012 5:52 AM