We are trying to build a page which displays the Asp.Net Application counters for caching and errors of a specific site.
The issue is that the method requires an instance to be passed into it. When I list out all the possible instances under my account, they look like the following:
I have six websites, all with dedicated application pools under IIS. Is there anyway to determine which instance is for a specific site? ARe these instances static, meaning, will they stay the same all the time?
I basically want to figure out which instance, if they are static, is for the site I want and pass it into a method to get the counters. The code below is what i used to display all available instances on my account out to screen.
If they aren't static or singular for each site, then I need ideas on how to do this.
PerformanceCounterCategory cat = new PerformanceCounterCategory("ASP.NET Applications");
string instances = cat.GetInstanceNames();
foreach (string instance in instances)
lblX.Text = lblX.Text + instance + "<br />";
//PerformanceCounter cnt = new PerformanceCounter("ASP.NET Applications", "Cache API Entries", instance);
//lblX.Text = lblX.Text + ", instance=" + instance + ":value=" + cnt.RawValue.ToString() + "<br />";