禁用behaviorExtensions的web.config继承

发布于 2024-11-30 03:01:30 字数 1733 浏览 1 评论 0原文

我正在尝试在 IIS 中的现有(根级别)网站下添加 Web 应用程序。根级网站的 web.config 文件在 system.serviceModel 下定义了某些行为扩展:

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

该扩展的使用方式如下:

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

由于某些原因,我不允许在添加的网站中添加对所需程序集的引用,因此我想禁用通过这种方式扩展的继承(当然在添加的网站的 web.config 中):

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

我还试图阻止扩展部分的继承,如下所示: <扩展><清除/>。不过,扩展节点似乎不支持

然而,当添加的网站上发生 WCF 错误时(问题出在第 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">

请考虑,不可能在根级别网站的 web.config 中禁止继承,因为其他添加的网站正在使用有问题的设置。

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 certain 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.

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

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

发布评论

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

评论(1

东北女汉子 2024-12-07 03:01:30

如果您能够在根 web.config 中使用 元素,那么您可以使用 inheritInChildApplications 选择不继承哪些部分> 属性:

例如:

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

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