Web.Config,system.serviceModel 的外部文件

发布于 2024-10-20 00:06:41 字数 1406 浏览 7 评论 0原文

使用 VS2010,

我的 web.config 中有以下内容(详细信息已删除)。

<system.serviceModel>
    <behaviors />
    <services />
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
    <bindings />
    <client />
</system.serviceModel>

我想使用与 appSettings 相同的属性 configSource 从另一个配置文件中获取这些元素的详细信息。

我尝试将 configSource 属性应用于 system.serviceModel 或每个子节点。 但是,我收到无效的蓝色波浪线:

The 'configSource' attribute is not allowed

我参考了这个问题中的第二个答案(汤姆兄弟),它演示了我想要的内容。
web.config 可以从外部 xml 文件读取吗?

附加
这是该帖子的配置。具有无效的蓝色波浪线。

<connectionStrings configSource="web\config\connectionStrings.config" /> 
<appSettings configSource="web\config\appSettings.config" /> 
<system.diagnostics configSource="web\config\diagnostics.config" /> 
<system.serviceModel> 
    <bindings configSource="web\config\serviceModelBindings.config" /> 
    <behaviors configSource="web\config\serviceModelBehaviors.config" /> 
    <services configSource="web\config\serviceModelServices.config" /> 
    <client configSource="web\config\serviceModelClient.config" /> 
</system.serviceModel> 

在这种情况下如何使用 configSource 属性?

Using VS2010

I have the following in my web.config (detail removed).

<system.serviceModel>
    <behaviors />
    <services />
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
    <bindings />
    <client />
</system.serviceModel>

I would like to use attribute configSource the same as appSettings can use to get the detail of these elements from another config file.

I have tried to apply configSource attribute to either system.serviceModel or to each of the sub nodes.
However, I get the invalid blue wavvy line saying:

The 'configSource' attribute is not allowed

I refer to the second answer (by Tom Brothers) in this question which demonstrates what I would like.
Can a web.config read from an external xml file?

Additional
Here is the configuration from that post. Has invalid blue wavvy lines.

<connectionStrings configSource="web\config\connectionStrings.config" /> 
<appSettings configSource="web\config\appSettings.config" /> 
<system.diagnostics configSource="web\config\diagnostics.config" /> 
<system.serviceModel> 
    <bindings configSource="web\config\serviceModelBindings.config" /> 
    <behaviors configSource="web\config\serviceModelBehaviors.config" /> 
    <services configSource="web\config\serviceModelServices.config" /> 
    <client configSource="web\config\serviceModelClient.config" /> 
</system.serviceModel> 

How can I use the configSource attibute in this case?

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

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

发布评论

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

评论(1

清眉祭 2024-10-27 00:06:41

您不能将 configSource= 应用于 ,因为这是一个配置部分 group - 不是一个简单的配置部分,并且 < code>configSource 属性仅在简单配置部分可用。

但是,您绝对应该能够将 configSource 属性应用到 内的任何节点 - 我在生产系统中一直这样做 - 而且它确实有效。你真的尝试过吗?

或者您是否让自己被 Visual Studio 吓跑了...它可能会向您显示(并告诉您)不允许使用 configSource=".​​..." (通过那些波浪下划线) - 但是这只是 Visual Studio 编辑器中的一个缺点 - 在 的子节点上,允许拥有 configSource= 属性!

您能否向我们展示(通过编辑您的原始问题)您的例如 serviceModelBehaviors.config 是什么样子?

另外:该文件实际上位于 Web 应用程序的 web\config 子目录中吗?

You cannot apply configSource= to <system.serviceModel> since that is a config section group - not a simple config section, and the configSource attribute is only available on simple configuration sections.

You should however absolutely be able to apply the configSource attribute to any of the nodes inside <system.serviceModel> - I do this all the time, in production systems - and it just works. Have you even really tried??

Or did you let yourself be scared off by Visual Studio... it might show you (and tell you) that configSource="...." is not allowed (by those wavy underlines) - but that's just a shortcoming in the Visual Studio editor - on the child nodes of <system.serviceModel>, it is allowed to have a configSource= attribute!

Can you show us (by editing your original question) what your e.g. serviceModelBehaviors.config looks like??

Also: is that file physically in the web\config subdirectory of your web application??

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