elmah on IIS 6 box

爱⌒轻易说出口 提交于 2019-12-23 15:37:05

问题


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.


回答1:


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" />


来源:https://stackoverflow.com/questions/4889633/elmah-on-iis-6-box

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!