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. To create Hit Counter in Asp.Net

To create Hit Counter in Asp.Net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelptutorial
4 Posts 4 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.
  • G Offline
    G Offline
    garga1
    wrote on last edited by
    #1

    Friends, Plse tell me how to create hit counter(should display in textbox or label) in Asp.Net using notepad. I dont want to have any database. When page loads texbox(or label) value should be incremented by 1. Plse help me... Thank you...

    R C T 3 Replies Last reply
    0
    • G garga1

      Friends, Plse tell me how to create hit counter(should display in textbox or label) in Asp.Net using notepad. I dont want to have any database. When page loads texbox(or label) value should be incremented by 1. Plse help me... Thank you...

      R Offline
      R Offline
      ReactiveX
      wrote on last edited by
      #2

      At the end of the day, you're going to end up using some sort of datasource. The simplest method would be to create a textfile (or preferrably XML if you know how to read it...) in your root directory for your web application. Read the text document on the page load using the System.IO.File.ReadAllText() method, assign the value to a variable on the page, increment it by one, save it back to the file using System.IO.File.WriteAllText() method and display the value to the label.

      Daniel Minnaar Lead Software Developer

      1 Reply Last reply
      0
      • G garga1

        Friends, Plse tell me how to create hit counter(should display in textbox or label) in Asp.Net using notepad. I dont want to have any database. When page loads texbox(or label) value should be incremented by 1. Plse help me... Thank you...

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        If you have no DB, you need to store the number in a text file, and just write code that handles the case of two users trying to read/write it at once.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        1 Reply Last reply
        0
        • G garga1

          Friends, Plse tell me how to create hit counter(should display in textbox or label) in Asp.Net using notepad. I dont want to have any database. When page loads texbox(or label) value should be incremented by 1. Plse help me... Thank you...

          T Offline
          T Offline
          The Cyclone
          wrote on last edited by
          #4

          U can add hit-counter to application state bag Application.Add("HitCount", 0); Now, u can retrieve this value any time, then do whatever u want & update the value int hitCount = Convert.ToInt32(Application["HitCount"]); hitCount++; Application["HitCount"] = hitCount;

          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