Symptom
When ASP. NET is used to create a new event source in the event log, you may receive the following error message:
System. Security. securityexception: Requested registry access is not allowed.
Cause
By default, the User Token of the ASP. NET workflow is ASPnet (or, for applications running on Internet Information Service [IIS] 6.0ProgramIs NetworkService ). Because your account does not have the correct user permission to create an event source, problems may occur in the "symptoms" section.
Temporary emergency measures:
There is a magic solution: houxy finds the "click out and select again in the anonymous access selection box of the IIS virtual directory" method:
First, do not enable Anonymous Access to the virtual directory of the site, so that you can access your web application as the local administrator, because your current identity should have permissions on the registry, so we can certainly do what the Enterprise Library wants to do. Then, enable Anonymous Access to the virtual directory and access the Web application again. Everything becomes normal and "system. Security. securityexception: Registry access requested is not allowed ." .
You can also change the anonymous account in "IIS virtual directory anonymous access" to an account with this permission. For example, the Administrator changes iusr_pyt to administrator.