Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Web.Config Transformations, replace entire ConnectionString section

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

like image 405
John Mc Avatar asked Jan 13 '23 10:01

John Mc


1 Answers

To replace entire connectionString section use the below code

<connectionStrings xdt:Transform="Replace">

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

like image 197
Mahesh Avatar answered Jan 20 '23 03:01

Mahesh