.Net Web.Config Transformations, replace entire ConnectionString section
Asked Answered
M

2

5

I've been using web.config transforms with good success. I've just recently implemented connection strings encryption and am unsure how to modify my Release transform.

Before hand I was simply replacing the setting by using the locator for name.

Now that the settings are encrypted, there is no name.

<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>

How can I update my transform to replace the entire connection strings section with this? Is there a locator for the element name "connectionStrings"?

Many thanks, John

Mako answered 9/9, 2013 at 9:55 Comment(0)
B
7

To replace entire connectionString section use the below code

<connectionStrings xdt:Transform="Replace">

xdt:Transform="Replace" Will do the trick. Cheers!!

Baucis answered 28/4, 2016 at 7:23 Comment(0)
M
4

Never mind, if you leave out the Locator it automatically applies it to the element.

Mako answered 9/9, 2013 at 10:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.