I need to store an escaped html string in a key in web.config using the KeyValueConfigurationElement.Save method built into framework 3.5. But when I try to do so, it keeps escaping my ampersands.
Code looks like this:
strHTML = DecodeFTBInput(FTB1.Text)
FTB1.Text is a string of HTML, like this: <b><font color="#000000">Testing</font></b>
DecodeFTPInput uses the String.Replace() method to change < and > to <
and >
, and " to "
.
Given the above string and function, let's say strHTML
now contains the following:
<b><font color="#000000">Testing</font></b>
Of course I can manually edit web.config to store the correct value, but I need the authenticated admin user to be able to change the html themselves.
The problem is that when I try to save this string into its key in web.config, it escapes all ampersands
as &
which ruins the string.
How can I get around this?