Skip to content

Need a code.

Prashant More

Asked Apr 23, 2008, 10:31 PM EDT2 answers
Share
LinkedInX

Hello friends,

I want to know the code to calculate how many no.of hits our site gets.OR how many persons visit our site.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    hi ,
    You can count the no of user requested your site by writing code in the global.asax file. in that file there is a method called application_sessionstart.create one variable which is a globar variable.
    0
  • Niradhip Chakraborty
    0

    You can refer the following URL:

    http://www.stardeveloper.com/articles/display.html?article=2002102501&page=1

    You also can refer the following code:


    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";
        }

    0