- ASP - Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


ASP Hit Counter
There are many ways to track usage of a website.  The simplest way is with a hit counter.  The code provided below is one of the simplest hit counters that can be made in .asp.  A text document (asp_count.txt) is placed in the same directory (providing that directory has write access, you may need to place the .txt document in your cgi-bin depending on your provider) as the page we want the counter to appear on.  The .txt file is first read to gain the value of the last hit count, one is added to that number, written to the .txt document, closed and the counter value is written as text to the page.  Refresh the content of the output page for a more complete illustration.
View the Output
Text View
Print View
Mail this Link
Download the Code

<title> Hit Counter)</title>
<body bgcolor="#FFFFFF">
on error resume next 

' Create a server object
set fso = createobject("scripting.filesystemobject")

' Target the text file to be opened
set act = fso.opentextfile(server.mappath("asp_count.txt"))

' Read the value of the text document
' If the text document does not exist then the on error resume next
' will drop down to the next line
counter = clng(act.readline)

' Add one to the counter
counter = counter + 1

' Close the object

' Create a new text file on the server
Set act = fso.CreateTextFile(server.mappath("asp_count.txt"), true)

' Write the current counter value to the text document

' Close the object

' Write the counter to the browser as text
Response.Write counter





ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3