【发布时间】:2013-08-11 15:35:14
【问题描述】:
我的情况是,我只想更新 WCF 端点的 URL 的一部分。现在,我们通过在每个“品种”的所有端点中包含不同的配置来做到这一点。这是繁琐的管理。我想在 web.config 中设置一个转换来这样做。
这是文件的两个示例
开发
<endpoint address="http://servicesdev.host.com/RPUtilityServices/LogException.svc/restService"
behaviorConfiguration="restfulBehavior"
binding="webHttpBinding"
contract="Host.RP.Shared.Common.Services.Utility.Interfaces.IExceptionUtilityService"
name="LogService" />
还有一些
分期
<endpoint address="http://servicessta.host.com/RPUtilityServices/LogException.svc/restService"
behaviorConfiguration="restfulBehavior"
binding="webHttpBinding"
contract="Host.RP.Shared.Common.Services.Utility.Interfaces.IExceptionUtilityService"
name="LogService" />
区别在于 servicessta 与 servicesdev。现在我也有 servicesuat 和 servicesqa 等。我想设置一个转换,将 'dev' 替换为 'sta' 等,而不是整个块(使用 xdt:Transform="Replace")
但是我该怎么做呢?
【问题讨论】:
-
只是好奇通过替换 url 的子字符串而不是整个属性可以获得什么?
-
我还有几个类似的块,restService,soap one 等。我将获得的是我只需要更新一个文件来替换服务地址而不是所有其他文件。我们有 5 个环境,因此替换使管理更容易。
-
我想我误解了你的帖子。当您真的只想更改属性时,我认为您想在属性上运行某种子字符串(至少这是我从您标记为正确的答案中得到的)。
-
不,你说得对,我只想替换子字符串。这是不可能的,所以我接受了正确的答案,因为它是下一个最佳选择。
标签: c# visual-studio-2012 web-config .net-4.5 web.config-transform