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

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(193)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2019-01-15 margin和text-align以及align
2019-01-15 inline-block和同级的text-align问题
2019-01-15 How to choose from Viewstate, SessionState, Cookies and Cache
2019-01-15 C#中的转义字符verbatim string
点击右上角即可分享
微信分享提示