Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7158349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:03:04+00:00 2026-05-28T13:03:04+00:00

I’m having trouble getting our multi-instance performance counter to work in ASP.NET MVC 3.

  • 0

I’m having trouble getting our multi-instance performance counter to work in ASP.NET MVC 3. Creating it as single instance works fine and running our multi-instance perf counter code in a simple console app works fine as well. But when I create it multi-instance and try to increment it using ASP.NET, it seams to struggle.

I don’t get an exception. I simply do not see any measurement output in perf mon. I can see the 2 instances, however.

This is the console app code to create the performance counter category:

private const string PERF_COUNTER_CATEGORY_NAME = "MvcPerformance";
private const string PERF_COUNTER_BASE_NAME = "MvcAction_Base";
private const string PERF_COUNTER_NAME = "MvcAction";

static void Main(string[] args)
{
    if (PerformanceCounterCategory.Exists(PERF_COUNTER_CATEGORY_NAME))
    {
        PerformanceCounterCategory.Delete(PERF_COUNTER_CATEGORY_NAME);
    }

    CounterCreationDataCollection counters = new CounterCreationDataCollection();

    // Add the counter.
    CounterCreationData avgDuration = new CounterCreationData();
    avgDuration.CounterType = PerformanceCounterType.AverageTimer32;
    avgDuration.CounterName = PERF_COUNTER_NAME;
    counters.Add(avgDuration);

    CounterCreationData avgDurationBase = new CounterCreationData();
    avgDurationBase.CounterName = PERF_COUNTER_BASE_NAME;
    avgDurationBase.CounterType = PerformanceCounterType.AverageBase;
    counters.Add(avgDurationBase);

    // Create the category.
    PerformanceCounterCategory.Create(PERF_COUNTER_CATEGORY_NAME, "Performance counters for MVC!", PerformanceCounterCategoryType.MultiInstance, counters);
}

Then our HomeController in the ASP.NET MVC app looks something like this:

    private static readonly Random _Random = new Random();
    private const string PERF_COUNTER_CATEGORY_NAME = "MvcPerformance";
    private const string PERF_COUNTER_BASE_NAME = "MvcAction_Base";
    private const string PERF_COUNTER_NAME = "MvcAction";
    private static PerformanceCounter _MvcActionCounter = new PerformanceCounter
    {
        CounterName = PERF_COUNTER_NAME, 
        CategoryName = PERF_COUNTER_CATEGORY_NAME,
        ReadOnly = false,
        InstanceName = "Home_Index",
    };
    private static PerformanceCounter _MvcActionCounterBase = new PerformanceCounter
    {
        CounterName = PERF_COUNTER_BASE_NAME,
        CategoryName = PERF_COUNTER_CATEGORY_NAME,
        ReadOnly = false,
        InstanceName = "Home_Index_Base",
    };

    public ActionResult Index()
    {
        Stopwatch s = new Stopwatch();
        s.Start();
        Thread.Sleep(_Random.Next(1000));
        s.Stop();

        // Increment the performance counters.
        _MvcActionCounter.IncrementBy(s.ElapsedMilliseconds);
        _MvcActionCounterBase.Increment();
        return View(new HomeViewModel { ElapsedTime = s.Elapsed });
    }

It’s probably something easy I’m forgetting. Maybe something to do with rights or user management?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:03:05+00:00Added an answer on May 28, 2026 at 1:03 pm

    A colleague of mine just mailed me the answer. The instance name of the base counter must be the same as the instance name of the average counter.

    If you encounter a problem like this, be sure that is the first thing you check… can save you a lot of time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to create an if statement in PHP that prevents a single post
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.