Free ASP counter (.asp)

The code bellow is prepared to be added to your asp page and it will automatically start counting hits for the page containning it. The script may be added to several pages to count hits in all of them, but it will be only one hit counter. To get hits in different pages individually, try this example

This code has been specifically create for you (next time you get to this page the code in red will change).

This script will automatically create a file named "counter777614.txt" within "cgi-bin"directory in your site (you may change the name of the file or the subdirectory within the script). This file will be used to save the number of times the page has been requested.

counter777614.asp
<% 
Set fs = CreateObject("Scripting.FileSystemObject")
Wfile=server.mappath("\") & "\cgi-bin\counter777614.txt"
on error resume next
Set a = fs.OpenTextFile(Wfile)
hits = Clng(a.ReadLine)
hits = hits 1
a.close

if error then
hits = 1
end if

Set a = fs.CreateTextFile(Wfile,True)
a.WriteLine(hits)
a.Close
%>
 

Number of hits: <% =hits %>

The number in your file will be increased each time your page is visited. Last line in this script will allow you to show the number of hits in your response page. 

Check a similar counter here. It will allow you to add a hit counter to your non-asp file. 

 

AspTutorial.info.