Chapter 22. Page Counter Component

There was a time that I'm sure many of you remember (not that long ago) when a page counter on a web site's home page was a novelty. Back then, adding a page counter required—or so it seemed—far more work than it was worth, involving at least a CGI application or maybe a Java applet.

The alternative was easier but fraught with difficulties of its own. It involved using a counter service. This involved adding an <IMG> tag to your site that referenced a CGI application on the counter service-maintained server. The service maintained the counter for you. The problem was that such services often were out of commission for long periods of time and would go down completely under heavy loads. Because counter services were problematic, many developers decided to create their own, often simply reinventing the wheel.

Now, however, the web is beginning to show signs that it has moved from infancy to its toddler years, and such mundane items as page counters have become everyday occurrences. There are now at least a dozen easily obtainable versions of the ever-present page counter. Microsoft has its own version; its Page Counter component is the topic of this chapter.

Microsoft's version of the Page Counter is a simple component that stores the current page count for a specific page to a text file. Code on your active server page increases the counter and retrieves the current count programmatically through calls to methods of the Page Counter object.

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.