149 lines
6.3 KiB
HTML
149 lines
6.3 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
|
|
<TITLE>Counters Component</TITLE>
|
|
<SCRIPT LANGUAGE="JavaScript">
|
|
<!--
|
|
TempString = navigator.appVersion
|
|
if (navigator.appName == "Microsoft Internet Explorer"){
|
|
// Check to see if browser is Microsoft
|
|
if (TempString.indexOf ("4.") >= 0){
|
|
// Check to see if it is IE 4
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
|
|
}
|
|
else {
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
|
|
}
|
|
}
|
|
else if (navigator.appName == "Netscape") {
|
|
// Check to see if browser is Netscape
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
|
|
}
|
|
else
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
|
|
//-->
|
|
</script>
|
|
<SCRIPT LANGUAGE="VBScript">
|
|
<!--
|
|
Sub Window_OnLoad()
|
|
Dim frmContents
|
|
On Error Resume Next
|
|
If Not Parent Is Nothing Then
|
|
Set frmContents = Parent.Contents
|
|
If Not frmContents Is Nothing Then
|
|
frmContents.Window.TOCSynch_Click
|
|
End If
|
|
End If
|
|
End Sub
|
|
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
|
|
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
|
|
<META NAME="MS.LOCALE" CONTENT="EN-US">
|
|
<META NAME="MS-IT-LOC" Content="Internet Information Services">
|
|
</HEAD>
|
|
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
|
|
|
|
<H1><A NAME="_counters_component"></A><SUP></SUP>Counters Component</H1>
|
|
|
|
<P>The Counter component creates a <B>Counters </B>object that can create, store, increment, and retrieve any number of individual counters. </P>
|
|
|
|
<P>A counter is a persistent value that contains an integer. You can manipulate a counter with the <B>Get</B>, <B>Increment</B>, <B>Set</B>, and <B>Remove </B>methods of the <B>Counters </B>object. Once you create the counter, it persists until you remove it.</P>
|
|
|
|
<P>Counters do not automatically increment on an event like a page hit. You must manually set or increment counters using the <A HREF="/iishelp/iis/htm/asp/comp1q0j.htm">Set</A> and <A HREF="/iishelp/iis/htm/asp/comp46lv.htm">Increment</A> methods.</P>
|
|
|
|
<P>Counters are not limited in scope. Once you create a counter, any page on your site can retrieve or manipulate its value. For example, if you increment and display a counter named <I>hits</I> in a page called Page1.asp, and you increment <I>hits</I> in another page called Page2.asp, both pages will increment the same counter. If you hit Page1.asp, and increment <I>hits</I> to 34, hitting Page2.asp will increment <I>hits</I> to 35. The next time you hit Page1.asp, <I>hits</I> will increment to 36.</P>
|
|
|
|
<P>All counters are stored in a single text file, Counters.txt, which is located in the same directory as the counters<I>.</I>dll file. </P>
|
|
|
|
<P>After you update, create or delete a counter, the IIS Services may need to be restarted before you see the change in the Counters.txt file.</P>
|
|
|
|
<TABLE border=0 cellpadding=5 cols=2 frame=box rules=all>
|
|
|
|
<TR VALIGN="top">
|
|
<TD class=blue width=22%><B>File Name</B></TD>
|
|
<TD class=blue width=78%><B>Description</B></TD>
|
|
</TR>
|
|
|
|
<TR VALIGN="top">
|
|
<TD width=22%>Counters.dll</TD>
|
|
<TD width=78%>The Counters component.</TD>
|
|
</TR>
|
|
|
|
<TR VALIGN="top">
|
|
<TD width=22%>Counters.txt</TD>
|
|
<TD width=78%>The file that stores all individual counters on a site. Counters.txt is a UTF8-encoded file. You can have any Unicode characters in a counter name. </TD>
|
|
</TR>
|
|
</TABLE><BR>
|
|
|
|
<H6>Syntax</H6>
|
|
|
|
<P>Create the <B>Counters</B> object one time on your server by adding the following to the Global.asa file:</P>
|
|
|
|
<PRE><CODE><B><OBJECT
|
|
RUNAT=Server
|
|
SCOPE=Application
|
|
ID=</B><I>Counter</I><B> </B>
|
|
<B>PROGID="MSWC.Counters"> </B>
|
|
<B></OBJECT></B>
|
|
</CODE></PRE>
|
|
|
|
<P><span class=le><B>Important</B></span></P>
|
|
|
|
<P>Only create one Counters object in your site. This single Counters object can create any number of individual counters.</P>
|
|
|
|
<P>For Internet Information Services on Windows<sup>®</sup> 95 or later, a Counters component has already been specified in the Global.asa file in the default virtual directory. You can work with the <B>Counters </B>object the component creates as if it were a built-in object by calling <B>Counters.Get</B>, <B>Counters.Increment</B>, <B>Counters.Remove</B>, and <B>Counters.Set</B>. You should not create another instance of the <B>Counters </B>object.</P>
|
|
|
|
<H6>Methods </H6>
|
|
|
|
<TABLE border=0 cellpadding=5 cols=2 frame=box rules=all>
|
|
|
|
<TR VALIGN="top">
|
|
<TD width=22%><A HREF="/iishelp/iis/htm/asp/comp1c37.htm">Get</A> </TD>
|
|
<TD width=78%>Returns the value of the counter. </TD>
|
|
</TR>
|
|
|
|
<TR VALIGN="top">
|
|
<TD width=22%><A HREF="/iishelp/iis/htm/asp/comp46lv.htm">Increment</A></TD>
|
|
<TD width=78%>Increases the counter by 1.</TD>
|
|
</TR>
|
|
|
|
<TR VALIGN="top">
|
|
<TD width=22%><A HREF="/iishelp/iis/htm/asp/comp02cz.htm">Remove</A></TD>
|
|
<TD width=78%>Removes the counter from the Counters.txt file. </TD>
|
|
</TR>
|
|
|
|
<TR VALIGN="top">
|
|
<TD width=22%><A HREF="/iishelp/iis/htm/asp/comp1q0j.htm">Set</A></TD>
|
|
<TD width=78%>Sets the value of the counter to a specific integer. </TD>
|
|
</TR>
|
|
</TABLE><BR>
|
|
|
|
<H6>Example</H6>
|
|
|
|
<P>Create an instance of the <B>Counters </B>object in the Global.asa file with the ID attribute set to <CODE>Counter</CODE>: </P>
|
|
|
|
<P>--- Global.asa ---</P>
|
|
|
|
<PRE><CODE><OBJECT
|
|
RUNAT=Server
|
|
SCOPE=Application
|
|
ID=Counters
|
|
PROGID="MSWC.Counters">
|
|
</OBJECT>
|
|
</CODE></PRE>
|
|
|
|
<P>You can then use that <B>Counters </B>object on one page to create all the counters you need:</P>
|
|
|
|
<PRE><CODE> Setting the Site Counter to <%= Counters.Set("SiteCounter", 1).
|
|
</CODE></PRE>
|
|
|
|
<P>Then on another page you can increment the counter in the following manner:</P>
|
|
|
|
<PRE><CODE> You are visitor number<%= Counters.Increment("SiteCounter ") %> to this page.
|
|
</CODE></PRE>
|
|
<hr class="iis" size="1">
|
|
<p align="center"><em><a href="../../../common/colegal.htm">© 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
|
|
</BODY>
|
|
</HTML>
|