ASP.NET Whidbey Overview
page 10 of 14
by Steven Smith
Feedback
Average Rating: 
Views (Total / Last 10 Days): 59373/ 165

Site Counters

Let's say you have a button on your page and you want to know how often it's clicked.  Or you just want to know how often users are viewing the pages in your application, but you're not a sysadmin and you don't want to deal with web logs and a log analyzer.  Well then, ASP.NET 2.0's site counters are for you.  These counters are built into the existing link and button controls, and use a built-in service or your own custom provider (the built-in service works with Sql Server or Access).  The counters simply track impressions and/or clicks over whatever timespan you specify (e.g. impressions/hour vs impressions/day -- one row of data will exist per timespan, so more granularity equals a larger database).

The main properties used for individual controls are CountClicks (bool), CounterGroup (string), and CounterName (string).  An example hyperlink:

 <asp:hyperlink  Text=“Click for Partner Details” NavigateUrl=“http://www.partnersite.com
CountClicks=“true”
CounterGroup=“PartnerClicks”
CounterName=“Partner1”
runat=“server” />

Before these counters will work, the site counters need to be set up using the ASP.NET configuration tool (which unfortunately appears to be broken in the build I'm using at the moment).
 
You can also specify site-level counters through a section in web.config.  The config section is <siteCounters> but the exact syntax seems to be still up in the air at this point.  Suffice to say, you will be able to specify individual page paths or wildcard paths of page groups/folders you would like to track activity on.

View Entire Article

User Comments

Title: very good article   
Name: raja raja
Date: 2009-12-04 7:57:23 AM
Comment:
very good and informative website.
Title: nice artical   
Name: abdulla hussein
Date: 2007-04-29 6:28:16 AM
Comment:
I like it , it is very informative . thanks alot man

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-12-08 11:58:38 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search