I am developing a CMS for a website that is already existing. How do I count the number of hits on the website? Please advise
<p>I am developing a CMS for an already existing website and I wish to add a counter to count the number of hits on the website. Below is my code. But this increases the counter everytime I refresh the page even if the website is not open at all Could you please advise me the error in my code?</p>

<pre><code> namespace HGS.HGSAdmin
{
public partial class FrmEnquiry : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int nCount = 99;
        nCount = GetCounterValue();
        DrawCounterValue(nCount);
    }

    private int GetCounterValue()
    {
        StreamReader ctrFile;
        FileStream ctrFileW;
        StreamWriter sw;

        string strPath = Server.MapPath("myappcounter.txt");
        string strCounterContents;
        int nCounter;
        if (File.Exists(strPath))
        {
            ctrFile = File.OpenText(strPath);
            strCounterContents = ctrFile.ReadLine().ToString();
            ctrFile.Close();
            nCounter = Convert.ToInt32(strCounterContents);
        }
        else

            nCounter = 0;
            nCounter++;
            ctrFileW = new FileStream(strPath, FileMode.OpenOrCreate, FileAccess.Write);
            sw = new StreamWriter(ctrFileW);
            sw.WriteLine(Convert.ToInt32(nCounter));
            sw.Close();
            ctrFileW.Close();


            return nCounter;

    }

    private void DrawCounterValue(int nCounter)
    {
        Response.Expires = 0;
        string strText = nCounter.ToString();
        string strFont = "Arial";
        int nSize = 10;
        Bitmap bmp = null;
        Graphics g = null;

        try
        {
            Font font = new Font(strFont, nSize);
            bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
            g = Graphics.FromImage(bmp);
            SizeF oSize = g.MeasureString(strText, font);
            int nWidth = (int)oSize.Width;
            int nHeight = (int)oSize.Height;

            Color clrFG = Color.FromName("Yellow");
            g.Dispose();
            bmp.Dispose();


            bmp = new Bitmap(nWidth, nHeight, PixelFormat.Format32bppArgb);
            g = Graphics.FromImage(bmp);
            g.DrawString(strText, font, new SolidBrush(clrFG), 0, 0);

            MemoryStream oStream = new MemoryStream();
            bmp.Save(oStream, ImageFormat.Gif);

            Response.ClearContent();
            Response.ContentType = "image/gif";
            Response.BinaryWrite(oStream.ToArray());

            Response.End();

        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
        finally
        {
            if(null!= g) g.Dispose();
            if(null!= bmp) bmp.Dispose();
        }

        }




        }
    }
</code></pre>
