<% If Request("DontFrame")<>1 Then Response.Redirect "/iissamples/sdk/asp/docs/SampFram.asp?ovfile=/iishelp/iis/htm/sdk/samp08tu.asp&srcfile=Components/PageCounter" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<META NAME="DESCRIPTION" CONTENT="Internet Information Server reference information"></HEAD>
<BODY BGCOLOR=#FFFFFF TEXT=#000000>
<font face="Verdana, Arial, Helvetica">
<h3><a name="_page_counter"></a>Page Counter</h3>
<p>
The Page Counter component creates a <b>PageCounter</b> object that can be used to count the number of times a Web page has been opened. The <b>PageCounter</b> object accesses count data from an internal data object, which periodically writes the information to a hit count data file. </p>
<p>
This example illustrates how to use the Page Counter component in an ASP script. The <b>PageCounter</b> object is instantiated, and the variable <i>MyPageCounter</i> is set to refer to the new instance. The <b>PageCounter.PageHit</b> method is called to increment the hit total. The <b>PageCounter.Hits</b> method is then called, which returns the number of hits the specified page has had. </p>
<p>
<b>Note</b> The Page Counter component increments the number of hits for a given page each time the <b>PageCounter.PageHit</b> 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. </p>
<p>
<b>Note</b> This component is not installed with IIS. You can install it from the Microsoft Web site at <a href="http://www.microsoft.com/iis/"><b>http://www.microsoft.com/iis/</b></a>, 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 <b>Server.CreateObject</b> invocation in this sample script must be modified to reflect the proper component ProgID.</p>