4010 An unhandled security exception has occurred. IIS 8.5

4010 An unhandled security exception has occurred. IIS 8.5

回答1

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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

 

看一下注册表Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application下面有没有对应的source

 

posted @ 2021-01-15 04:28  ChuckLu  阅读(181)  评论(0编辑  收藏  举报