Name

Hits — objPgCntr .Hits( [strPathInfo ])

Synopsis

Retrieves a Long from the Page Counter hits file representing the total number of times a given page has been requested.

Parameters

strPathInfo

The virtual path and filename for the page whose hit count you wish to retrieve. If you do not include a strPathInfo argument, the Page Counter object will retrieve the number of times the current page has been requested.

Example

<%

' Declare local variables.
Dim objPgCntr
Dim lngHitCount

' Instantiate a Page Counter object.
Set objPgCntr = Server.CreateObject( _
                "MSWC.PageCounter")

' Retrieve the hit count for the home page.
lngHitCount = objPgCntr.Hits("/Apps/Homepage.asp")
%>

The home page has been served <%= lngHitCount %> times.

Notes

As explained earlier, a page's hit count is updated automatically (assuming that page contains a Page Counter object) any time a user requests it. This number shows both "new" requests and those produced from simply clicking on the Refresh button.

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.