Performance Counters and Security Exceptions

If you try to create a Performance Counter in ASP.NET, you will get a happy reply when you run it:

Requested registry access is not allowed.

Simply, the ASPNET account doesn’t have access to the Registry to create them.

There are several solutions, but the one I hear most is changing the context the ASPNET account is using in machine.config to use “SYSTEM” instead of the default “MACHINE”. This works, but opens up some security no-no’s.

The best fix that I found is to grant the neccessary permissions to the aspnet wp account (ASPNET) in the registry.

  1. Open regedt32 (not just regedit).
  2. Go to HKEY LOCAL MACHINE\System\CurrentControlSet\Services\EventLog
  3. Right click on “Security” and select “Permissions…” in the menu
  4. Add the ASPNET account for the local machine and place a check next to “Full Control”

  5. Restart IIS

If that doesn’t work, create a directory under \Services and call it the name of your performance counter you are trying to create. Then give the ASPNET account access to that.

Leave a Reply

Your email address will not be published. Required fields are marked *