IIS 6 上的 elmah
我有一个网站,上面运行着 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑您的托管服务商正在中等信任度下运行 ASP.NET。有几件事需要尝试。
将
requirePermission="false"
属性添加到web.config
中声明的每个 Elmah 配置部分,例如:如果这不起作用,您也可以尝试覆盖通过将其添加到
web.config
文件中的
来设置信任级别:如果这不起作用,那么您可能需要联系您的托管服务商并询问他们放宽信托政策。但是,如果您的网站位于共享池中,他们不太可能接受这一点。
更新:
关于
requirePermission
属性:默认的“中等信任”策略不允许部分受信任的调用者访问配置文件设置,即使在您自己的应用程序中也是如此。您可以通过设置
requirePermission="false"
来选择覆盖应用程序的本地配置设置。这是在web.config
文件中的声明中完成的。因此,当您设置:
实际上您所说的是请授予 Elmah 读取此设置的权限:
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 yourweb.config
, for example:If this doesn't work you could also try overriding the trust level by adding this to
<system.web>
in yourweb.config
file: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 yourweb.config
file. So, when you set:Effectively what your saying is please grant Elmah permission to read this setting: