Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Count visitors

Count visitors

Scheduled Pinned Locked Moved ASP.NET
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheEagle
    wrote on last edited by
    #1

    What is the best way to count my website visitors? "I am too late but i will never give up"

    S A 2 Replies Last reply
    0
    • T TheEagle

      What is the best way to count my website visitors? "I am too late but i will never give up"

      S Offline
      S Offline
      sood_is_in
      wrote on last edited by
      #2

      well you can keep a counter in global.asax in session _Start event Enjoy Coding

      T 1 Reply Last reply
      0
      • T TheEagle

        What is the best way to count my website visitors? "I am too late but i will never give up"

        A Offline
        A Offline
        amaneet
        wrote on last edited by
        #3

        In the global.aspx file Application_start() application("visitor")=0 Now at Webpage load Application("c") = CType(Applicatrion("visitor") , integer) + 1 Label1.text = "You ar visitor no " & Application("c")

        T 1 Reply Last reply
        0
        • S sood_is_in

          well you can keep a counter in global.asax in session _Start event Enjoy Coding

          T Offline
          T Offline
          TheEagle
          wrote on last edited by
          #4

          Hi.. Thank you for your respond..I know how to use the application and session state variables and i have used the following code : protected static int m_ActiveUsers; public static int ActiveUsers { get { return m_ActiveUsers; } } protected void Application_Start(Object sender, EventArgs e) { Application.Lock(); m_ActiveUsers=0; Application.UnLock(); } protected void Session_Start(Object sender, EventArgs e) { Application.Lock(); ++m_ActiveUsers; Application.UnLock(); } protected void Session_End(Object sender, EventArgs e) { Application.Lock(); --m_ActiveUsers; Application.UnLock(); } But the problem it doesnt give me the right number always.Some times this code tells me there is two visitors while there is no one except me.And some times it doesnt decrement the visitors count number when i exit. Do any one know how to make a better way that wont be affected by application errors and will solve my problem? :confused: "I am too late but i will never give up"

          1 Reply Last reply
          0
          • A amaneet

            In the global.aspx file Application_start() application("visitor")=0 Now at Webpage load Application("c") = CType(Applicatrion("visitor") , integer) + 1 Label1.text = "You ar visitor no " & Application("c")

            T Offline
            T Offline
            TheEagle
            wrote on last edited by
            #5

            Hi.. Thank you for your respond..I think your code will count how many times the Web Form has been loaded not how many visitors are viewing my website currently!. I am too late but i will never give up

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups