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. current viewrs count

current viewrs count

Scheduled Pinned Locked Moved ASP.NET
help
5 Posts 5 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.
  • R Offline
    R Offline
    ratnakar_ravi
    wrote on last edited by
    #1

    hi, i want to know viewsrs count at a particular time who r viewing my site i hav tried this using global.aspx but no use plz help me thanks in adv

    A B N 3 Replies Last reply
    0
    • R ratnakar_ravi

      hi, i want to know viewsrs count at a particular time who r viewing my site i hav tried this using global.aspx but no use plz help me thanks in adv

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      ratnakar_ravi wrote:

      i hav tried this using global.aspx but no use

      How did you tried with Global.aspx, can you please put the code of Session_Start() Method.

      cheers, Abhijit My Recent Article : Beginner's Guide To View State

      1 Reply Last reply
      0
      • R ratnakar_ravi

        hi, i want to know viewsrs count at a particular time who r viewing my site i hav tried this using global.aspx but no use plz help me thanks in adv

        B Offline
        B Offline
        Brij
        wrote on last edited by
        #3

        Take a application level variable.Increase the count by 1 on every session start and Decrease when session ends in Global.asax.

        Cheers!! Brij

        M 1 Reply Last reply
        0
        • B Brij

          Take a application level variable.Increase the count by 1 on every session start and Decrease when session ends in Global.asax.

          Cheers!! Brij

          M Offline
          M Offline
          mr_muskurahat
          wrote on last edited by
          #4

          and your session mode in global.asax must be set to InProc otherwise session_end event will not call.....

          umerumerumer

          1 Reply Last reply
          0
          • R ratnakar_ravi

            hi, i want to know viewsrs count at a particular time who r viewing my site i hav tried this using global.aspx but no use plz help me thanks in adv

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            ratnakar_ravi wrote:

            global.aspx

            :confused: You can use Application variable to keep the current viewer count. Increase the count in Session_Start event and decrease it when the session ends. ASP.NET is multithreaded so application variables are not thread safe. Make sure you always use a lock around the operations. Something like

            Application.Lock();
            int currentViewerCount = int.Parse(Application["viewers"]);
            Application["viewers"] = currentViewerCount + 1;
            Application.UnLock();

            Navaneeth How to use google | Ask smart questions

            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