Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ASP.NET performance data not available after installing .NET 4.5


View products that this article applies to.

Symptoms

After installing .NET 4.5 you are not able to access performance data using WMI. For example, when you try to get the value for the Win32_PerfFormattedData_ASPNET_ASPNETApplications performance counter, the value returned using WMI is always 0.

↑ Back to the top


Cause

This is by design as a security fix. Only admin and performance log/monitor can access asp.net performance information.

↑ Back to the top


Resolution

To workaround the issue, you can use C# code executed with admin privilege to query the performance info like this:

namespace PerfCounterQuery
{
using System;
using System.Diagnostics;
using System.Collections.Generic;

class Program PerfCounterQuery
{

static void Main(string[] args)
{

IntPtr userHandle = new IntPtr(0);
string hostName = ".";
string categoryName = "ASP.NET Applications";
string instanceName = "__Total__";
string [] counterNames = { "Anonymous Requests" };
PerformanceCounterCategory cat = new PerformanceCounterCategory(categoryName, hostName);
List <PerformanceCounter> counters = new List<PerformanceCounter>();
foreach (string counterName in counterNames)
{
if (!PerformanceCounterCategory.CounterExists(counterName, categoryName, hostName))
{
Console.WriteLine("perf counter \"" + counterName + "\" does not exist");return;
}
counters.Add(new PerformanceCounter(categoryName, counterName, instanceName, hostName));}

foreach (PerformanceCounter counter in counters)
Console.WriteLine(counter.CategoryName + " - " + counter.CounterName + " : " + counter.NextValue());

}
}
}

↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 2869514
Revision : 1
Created on : 1/7/2017
Published on : 8/15/2013
Exists online : False
Views : 140