This class implements Page Counter Component in C#.
Page Counter Component for .NET creates a PageCounter object that counts and displays the number of times a Web page has been opened.
All counters are stored in a single text file, PageCounter.txt, which is located in the IIS root directory. Generally it is in C:\Inetpub\wwwroot directory.
For the details about Page Counter Component, please refer to the IIS hlep of Microsoft.
Following is the nce.mswc.PageCounter class reference.
Methods | Description |
Hits | Displays the number of times that a specified URL has been opened. |
PageHit | Increments the Hit Count. |
Reset | Sets the hit count for a specified page to 0. |
Set | Sets the value of the counter to a specific integer. |
The following example displays a different tip of the day each time a user views the Web page.
<% Set MyPageCounter = Server.CreateObject("MSWC.PageCounter") HitMe = MyPageCounter.Hits If HitMe = 1000000 Then %> You are the lucky 1,000,000th Customer!!! <BR> <% Else %> Sorry, you are customer #<%= HitMe %> <BR> <% End If %> |
ASP2ASPX will convert above codes to following:
<% Dim MyPageCounter As nce.mswc.PageCounter Dim HitMe As Integer MyPageCounter = new nce.mswc.PageCounter() HitMe = MyPageCounter.Hits() If HitMe = 1000000 Then %> You are the lucky 1,000,000th Customer!!! <BR> <% Else %> <% MyPageCounter.PageHit() %> Sorry, you are customer #<%= HitMe %> <BR> <% End IF %> |