If you try to create a Performance Counter in ASP.NET, you will get a happy reply when you run it:
System.Security.SecurityException:
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.
- Open regedt32 (not just regedit).
- Go to HKEY LOCAL MACHINE\System\CurrentControlSet\Services\EventLog
- Right click on “Security” and select “Permissions…” in the menu
- Add the ASPNET account for the local machine and place a check next to “Full Control”
- 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.