<% If Request("DontFrame")<>1 Then Response.Redirect "/iissamples/sdk/asp/docs/SampFram.asp?ovfile=/iishelp/iis/htm/sdk/samp08tu.asp&srcfile=Components/PageCounter" %> Page Counter

Page Counter

The Page Counter component creates a PageCounter object that can be used to count the number of times a Web page has been opened. The PageCounter object accesses count data from an internal data object, which periodically writes the information to a hit count data file.

This example illustrates how to use the Page Counter component in an ASP script. The PageCounter object is instantiated, and the variable MyPageCounter is set to refer to the new instance. The PageCounter.PageHit method is called to increment the hit total. The PageCounter.Hits method is then called, which returns the number of hits the specified page has had.

Note The Page Counter component increments the number of hits for a given page each time the PageCounter.PageHit method is called. If your script does not call this method exactly once per page hit, your page hit count will be inaccurate for that page.

Note This component is not installed with IIS. You can install it from the Microsoft Web site at http://www.microsoft.com/iis/, or from the CD included with the IIS Resource Kit. The ProgID declared by the component version installed from these sources specifies "IISSamples" in the vendor component of the ProgID, not "MSWC." Therefore, the Server.CreateObject invocation in this sample script must be modified to reflect the proper component ProgID.


© 1997 by Microsoft Corporation. All rights reserved.