4010 An unhandled security exception has occurred. IIS 8.5
4010 An unhandled security exception has occurred. IIS 8.5
I had this issue today and it was due to my asp.net application wanting to write to the Windows Event Log. The Event Source didn't exist and my application didn't have the permissions to create it so it errored with this message:
Event code: 4010 Event message: An unhandled security exception has occurred.
The fix for me was to create the Event Source and my application started working. I followed the steps from the below answer to manually create the Event Source via the command line:
How to create Windows EventLog source from command line?
回答2
In IIS, try increasing your site's .NET Trust Level to Full (internal).
In IIS, trust levels are used to determine the permissions and restrictions that ASP.NET applications have to access system resources. A trust level is a set of permissions that an application has to perform specific actions. There are four trust levels in ASP.NET, which are:
-
Full trust: This is the highest trust level that an application can have. An application with full trust has unrestricted access to system resources and can perform any action that the application pool identity can perform.
-
High trust: Applications with high trust can access most of the resources on the system, but not all. For example, high-trust applications cannot access the registry or use reflection to access private members of an object.
-
Medium trust: Applications with medium trust have more restrictions than those with high trust. They cannot access some resources, such as the registry and network resources, and are limited in their ability to use reflection.
-
Low trust: Applications with low trust have the most restrictions. They cannot access many system resources, including the file system, registry, and network resources, and cannot use reflection.
By default, ASP.NET applications run in the medium trust level in IIS. However, administrators can configure the trust level for individual applications by modifying the web.config file.
How to create Windows EventLog source from command line? - Stack Overflow
Try "eventcreate.exe"
An example:
eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO MYEVENTSOURCE /D "My first log"
This will create a new event source named MYEVENTSOURCE
under APPLICATION
event log as INFORMATION
event type.
I think this utility is included only from XP onwards.
Further reading
-
Windows IT Pro: JSI Tip 5487. Windows XP includes the EventCreate utility for creating custom events.
-
Type
eventcreate /?
in CMD prompt -
Microsoft TechNet: Windows Command-Line Reference: Eventcreate
-
SS64: Windows Command-Line Reference: Eventcreate
看一下注册表Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application下面有没有对应的source