禁用behaviorExtensions的web.config继承
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您能够在根
web.config
中使用
元素,那么您可以使用inheritInChildApplications
选择不继承哪些部分> 属性:例如:
If you are able to use the
<location>
element in the rootweb.config
then you can chose which sections not to inherit using theinheritInChildApplications
attribute:For example: