.Net Web.Config转换,替换整个ConnectionString部分

5

我一直成功地使用web.config变换。最近,我刚刚实现了连接字符串加密,不确定如何修改我的发布变换。

之前,我只是使用名称定位器替换设置。

现在,由于设置已加密,没有名称可用。

<connectionStrings configProtectionProvider="Pkcs12Provider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
  xmlns="http://www.w3.org/2001/04/xmlenc#">
  <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes192-cbc" />
  <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
    <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <KeyName>rsaKey</KeyName>
      </KeyInfo>
      <CipherData>
        <CipherValue>CipherValueHere</CipherValue>
      </CipherData>
    </EncryptedKey>
  </KeyInfo>
  <CipherData>
    <CipherValue>CipherValueHere</CipherValue>
  </CipherData>
</EncryptedData>

我该如何更新我的转换器来替换整个连接字符串部分为以下内容?是否有一个元素名为“connectionStrings”的定位器?

非常感谢, 约翰

2个回答

7

要替换整个connectionString部分,请使用以下代码

<connectionStrings xdt:Transform="Replace">

xdt:Transform="Replace"会起到作用。祝贺!


4
不用担心,如果你省略定位器,它会自动将其应用于元素。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接