【问题标题】:web.config transform not working correctlyweb.config 转换无法正常工作
【发布时间】:2013-08-06 01:25:30
【问题描述】:

我们在 VS 2012 中创建了一个网站。我们右键单击了 web.config 文件并选择了“添加配置转换”并创建了 web.config 的发布和调试版本。

在其中,我们在web.config 的调试和发布版本中的<appSettings> 部分添加了一些新条目:

  <appSettings>
    <add key="username" value="user" xdt:Transform="Insert" xdt:Locator="Match(key)"/>
    <add key="password" value="pwd" xdt:Transform="Insert" xdt:Locator="Match(key)"/>
    <add key="GET" value="https://somewhere.com/url1" xdt:Transform="Insert" xdt:Locator="Match(key)"/>
    <add key="POST" value="https://somewhere.com/url2" xdt:Transform="Insert" xdt:Locator="Match(key)"/>

  </appSettings>

我们已经尝试了各种转换类型,包括“插入”和“设置属性”。到目前为止,还没有产生在构建后将这些新的 appSettings 条目添加到 web.config 的预期结果。

我们是否需要在web.config 中为它们添加占位符条目,还是我们缺少其他步骤?

[编辑] 上面的 appSettings 包含在 web.config 的调试和发布版本中的 &lt;configuration&gt; 元素中。

【问题讨论】:

    标签: visual-studio-2012 web-config


    【解决方案1】:

    我的猜测是插入和定位器不能一起工作。如果您正在执行插入操作,则不会尝试在任何内容上匹配它。如果您尝试进行替换或设置某些属性,则需要进行定位器匹配。如果您正在执行插入操作,则无需查找(使用定位器),因为它是全新的。

    简而言之,如果这是一个新条目,请离开插入,放下定位。

    有意义吗?

    【讨论】:

      猜你喜欢
      • 2013-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多