我们必须转换标签,其中的"decryptionKey“和"validationKey”对于我们的开发和测试环境是不同的。
我们尝试为validationKey和decryptionKey提供不同的变量,但与xdt: Transform和xdt: Locator属性混淆,因为它们将在同一标记中出现一次。
假设下面是web.config machineKey标签,
<machineKey decryptionKey="012345678910111213141516"
validation="SHA1" validationKey="235487512547896321458778996325456965542126364586965" />我们必须给出类似如下的变换,
<machineKey decryptionKey="#{DecryptionKey}#"
validation="SHA1"
validationKey="#{ValidationKey}#"
xdt:Transform="SetAttributes"
xdt:Locator="Match(decryptionKey)"
xdt:Transform="SetAttributes"
xdt:Locator="Match(validationKey)" />需要这样一种解决方案,在这种解决方案中,我们必须在单个标记中给出多个变量。
发布于 2019-04-09 06:12:25
要设置多个属性,需要将它们作为逗号分隔的列表传递给SetAttributes。
这是文档化的here
但是,如果您实际上要替换所有属性,那么使用xdt:Transform="Replace"并在每个配置中设置整个标记值可能会更容易/更干净。
https://stackoverflow.com/questions/55568217
复制相似问题