IIS 6 上的 elmah

发布于 2024-10-16 01:27:26 字数 741 浏览 3 评论 0原文

我有一个网站,上面运行着 elmah,记录到一个 sql 框。在我的测试环境中,它是 IIS 7 机器,一切运行良好。当我上传到运行 IIS 6 的网络解决方案网站时,出现错误“

[SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +58
   System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) +99

网站已设置为运行 .net 3.5”。我们所有的页面都工作正常,但 elmah 给出了这个错误。我已经进行了一些搜索,但找不到我设置不正确的内容。希望其他人已经解决了这个问题。

I've got a web site with elmah running on it logging to a sql box. In my test env it's a IIS 7 machine and all works well. When i upload to a network solutions web running IIS 6 I get an error

[SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +58
   System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) +99

The website is setup to run .net 3.5. All of our pages work fine, but elmah gives this error. I've done some searching but can't find what i've setup incorrectly. Was hoping someone else has already solved this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫﹏色ふ单纯 2024-10-23 01:27:26

我怀疑您的托管服务商正在中等信任度下运行 ASP.NET。有几件事需要尝试。

requirePermission="false" 属性添加到 web.config 中声明的每个 Elmah 配置部分,例如:

<sectionGroup name="elmah">
  <section name="security" type="Elmah.SecuritySectionHandler, Elmah" 
           requirePermission="false"/>
  <section name="errorLog" type="Elmah.ErrorLogSectionHandler, Elmah" 
           requirePermission="false"/>
</sectionGroup>

如果这不起作用,您也可以尝试覆盖通过将其添加到 web.config 文件中的 来设置信任级别:

<trust level="Full"/>

如果这不起作用,那么您可能需要联系您的托管服务商并询问他们放宽信托政策。但是,如果您的网站位于共享池中,他们不太可能接受这一点。

更新:

关于 requirePermission 属性:默认的“中等信任”策略不允许部分受信任的调用者访问配置文件设置,即使在您自己的应用程序中也是如此。

您可以通过设置 requirePermission="false" 来选择覆盖应用程序的本地配置设置。这是在 web.config 文件中的

声明中完成的。因此,当您设置:

<section name="errorLog" type="Elmah.ErrorLogSectionHandler, Elmah" 
       requirePermission="false"/

实际上您所说的是请授予 Elmah 读取此设置的权限:

<errorLog type="Elmah.VistaDBErrorLog, Elmah" connectionStringName="ElmahDB" />

I suspect your hoster is running ASP.NET in Medium Trust. There's a couple of things to try.

Add the requirePermission="false" attribute to each of the Elmah configuration sections declared in your web.config, for example:

<sectionGroup name="elmah">
  <section name="security" type="Elmah.SecuritySectionHandler, Elmah" 
           requirePermission="false"/>
  <section name="errorLog" type="Elmah.ErrorLogSectionHandler, Elmah" 
           requirePermission="false"/>
</sectionGroup>

If this doesn't work you could also try overriding the trust level by adding this to <system.web> in your web.config file:

<trust level="Full"/>

If this doesn't work then you may need to contact your hoster and ask them to relax their trust policy. However if your site is in a shared pool it's unlikely that they'll entertain this.

Update:

About the requirePermission attribute: The default Medium Trust policy doesn't permit partially trusted callers access to configuration file settings, even in your own application.

You can elect to override this for your application's local configuration settings by setting requirePermission="false". This is done in the <section name="..." type="..." /> declarations in your web.config file. So, when you set:

<section name="errorLog" type="Elmah.ErrorLogSectionHandler, Elmah" 
       requirePermission="false"/

Effectively what your saying is please grant Elmah permission to read this setting:

<errorLog type="Elmah.VistaDBErrorLog, Elmah" connectionStringName="ElmahDB" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文