开发者

Disabling web.config inheritance for behaviorExtensions

开发者 https://www.devze.com 2023-03-28 15:05 出处:网络
I\'m trying to add a web application in IIS under an existing (root level) website. The root level website\'s web.config file defines certain behaviorExtensions under system.serviceModel:

I'm trying to add a web application in IIS under an existing (root level) website. The root level website's web.config file defines certain behaviorExtensions under system.serviceModel:

    <extensions>
        <behaviorExtensions>
            <add name="errorHandler" type="API.ErrorHandler.WCFErrorHandlerElement, API.ErrorHandler, Version=1.5.1.832, Culture=neutral, PublicKeyToken=null" />
        </behaviorExtensions>
    </extensions>

The extension is used like this:

        <serviceBehaviors>
            <behavior name="DefaultRESTBasedHTTPSServiceBehavior">
                <errorHandler />
            </behavior>
        </serviceBehaviors>

For c开发者_如何学运维ertain reasons I'm not allowed to add a reference to the required assembly in the added website, so I want to disable the extension's inheritance by this way (in the added website's web.config of course):

<behaviors>      
  <serviceBehaviors>
    <clear/>
  </serviceBehaviors>
  <endpointBehaviors>
    <clear/>
  </endpointBehaviors>
</behaviors>

I was also trying to prevent the inheritance of the extensions section like this: <extensions><clear/></extensions>. It seems though, that <clear/> is not supported for the extensions node.

Yet I get the following exception when a WCF error happens on the added website (the problem is at Line 191):

Parser Error Message: The type 'API.ErrorHandler.WCFErrorHandlerElement, API.ErrorHandler, Version=1.5.1.832, Culture=neutral, PublicKeyToken=null' registered for extension 'errorHandler' could not be loaded.

Line 189:           <serviceBehaviors>
Line 190:               <behavior name="DefaultRESTBasedHTTPSServiceBehavior">
Line 191:                   <errorHandler />
Line 192:               </behavior>
Line 193:               <behavior name="DefaultSOAPBasedHTTPSServiceBehavior">

Please consider, that it is not possible to prohibit inheritance in the root level website's web.config, because other added websites are using the settings in question.


If you are able to use the <location> element in the root web.config then you can chose which sections not to inherit using the inheritInChildApplications attribute:

For example:

<location path="MyWebApp" inheritInChildApplications="false">
    <system.serviceModel>
    </system.serviceModel>
</location>
0

精彩评论

暂无评论...
验证码 换一张
取 消