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
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.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