In my web.config file I have the following entry:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<machineKey validationKey="656....9CCF" decryptionKey="9020.....659" validation="SHA1" decryption="AES" />
</system.web>
</configuration>
I need to swap the validationKey and decryptionKey values under certain web publish profiles using the web config transform method. I'm struggling however, as I can't find any examples that achieve more than a basic connection string swap, or suchlike.
Is it possible to actually modify this part of the file using config transforms?
My attempt so far doesn't get recognised when I preview the transform...
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<machineKey validationKey="AE3E7...FAB49" decryptionKey="ADS32....32423twe" xdt:Transform="Replace" xdt:Locator="Match(validationKey)" />
</system.web>
</configuration>
You can use something like this:
<machineKey validationKey="AE3E7...FAB49" decryptionKey="ADS32....32423twe"
xdt:Transform="SetAttributes" xdt:Locator="XPath(../machineKey)"/>
Note that I replaced the xdt:Transform to "SetAttributes" not "Replace".
For more reference you can check msdn page.
You can also test the transform here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With