【问题标题】:Asp.Net MVC - SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: SecurityAsp.Net MVC - SecurityException:找不到源,但无法搜索部分或全部事件日志。无法访问的日志:安全性
【发布时间】:2019-04-03 19:37:40
【问题描述】:

因此,我使用 Visual Studio 中的 AWS Toolkit Extension 通过 AWS Elastic Beanstalk(附加了一个 AWS RDS 实例)部署我的网站。我的网络应用程序同时使用 sensenet 服务和 sensenet 网页组件。 sensenet 服务是必需的组件,必须存在才能使用其他 sensenet 组件。 sensnet 网页组件为用户提供了一个管理 GUI,这是每当有人访问该网站时都会显示的内容。

我的问题是每次访问我的网站都会出现这个安全异常(通过localhost运行时不会出现这个问题)。

Server Error in '/' Application.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.]
   System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate) +441
   System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate) +125
   System.Diagnostics.EventLog.SourceExists(String source) +23
   SenseNet.Diagnostics.SnEventLogger..ctor(String logName, String logSourceName) +71
   SenseNet.Configuration.<>c.<.ctor>b__153_0() in E:\BuildAgent\_work\63\s\src\Storage\Configuration\Providers.cs:83
   System.Lazy`1.CreateValue() +708
   System.Lazy`1.LazyInitValue() +184
   SenseNet.ContentRepository.RepositoryInstance.InitializeLogger() in E:\BuildAgent\_work\63\s\src\ContentRepository\RepositoryInstance.cs:350
   SenseNet.ContentRepository.RepositoryInstance.DoStart() in E:\BuildAgent\_work\63\s\src\ContentRepository\RepositoryInstance.cs:130
   SenseNet.ContentRepository.RepositoryInstance.Start(RepositoryStartSettings settings) in E:\BuildAgent\_work\63\s\src\ContentRepository\RepositoryInstance.cs:107
   SenseNet.ContentRepository.Repository.Start(RepositoryStartSettings settings) in E:\BuildAgent\_work\63\s\src\ContentRepository\Repository.cs:55
   SenseNet.Services.SenseNetGlobal.Application_Start(Object sender, EventArgs e, HttpApplication application) in E:\BuildAgent\_work\63\s\src\Services\SenseNetGlobal.cs:156
   DERContentRepository.MvcApplication.Application_Start(Object sender, EventArgs e, HttpApplication application) in Global.asax.cs:12
   SenseNet.Portal.Global.Application_Start(Object sender, EventArgs e) in E:\BuildAgent\_work\63\s\src\Services\Global.cs:16

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3163.0

我读过的几篇类似这样的 stackoverflow 帖子

System.Security.SecurityException when writing to Event Log

The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

谈到以管理员身份运行 Visual Studio(这不起作用)和 使用应用程序的名称创建注册表项。最后一种方法我很确定它可以在开发中使用,但不确定它在部署时是否可以使用。部署网站时如何处理这个问题?

IIS Express 10

ASP.NET MVC v4.6.2

Windows Server 2016 v1.2.0

【问题讨论】:

    标签: c# asp.net amazon-web-services sensenet aws-toolkit


    【解决方案1】:

    当系统启动时,它会尝试初始化记录器组件。在默认安装中,这是一个简单的事件记录器,它会尝试将事件写入 Windows 事件日志 - 如果相应的日志不存在,它会尝试即时创建它。在某些环境中,应用程序用户对此没有 (Windows) 权限,这是正常的。

    您有多种选择:

    • 手动创建事件日志(参见createeventlogSnAdmin 工具here
    • 使用不同的记录器将日志条目写入其他位置,而不是事件日志。例如,有 SnFileSystemEventLogger 将条目写入文件系统。要配置记录器,您可以在 MvcApplication 中使用存储库构建器 API:

    ```

    public class MvcApplication : SenseNet.Portal.SenseNetGlobal
    {
        protected override void Application_Start(object sender, EventArgs e, HttpApplication application)
        {
            ...
        }
    
        protected override void BuildRepository(IRepositoryBuilder repositoryBuilder)
        {
            repositoryBuilder.UseLogger(new SnFileSystemEventLogger());
        }
    }
    

    【讨论】:

    • 感谢米克洛斯的帮助。我选择了文件系统解决方案,它确实摆脱了那个异常。不幸的是,弹出另一个异常。这是指向它的链接hastebin.com/nubowesaru.coffeescript 注意在我的 inetpub 文件夹中没有 wwwroot 文件夹。在堆栈跟踪的开头,我看到调用 InternalCreateDirectory 它可能在没有适当权限的情况下创建文件夹,并且在尝试访问文件夹时失败(只是我的猜测)。
    • 我明白了,所以另一个例外与授予 aws elasticbeanstalk 文件系统写访问权限有关。幸运的是,有一篇与此问题相关的 stackoverflow 帖子。 stackoverflow.com/questions/28621421/…
    猜你喜欢
    • 2014-08-05
    • 2011-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-19
    • 2012-03-22
    • 1970-01-01
    相关资源
    最近更新 更多