ConnectionStrings in app.config with characters that the .config file does not like

I was looking for an answer and can not find it. It should be something obvious, and I just missed it.

We have a problem with the connection string in the app.config file. It uses SQL Server authentication, and the password contains "&". and the symbol "+". Obviously the parsing is going wrong. At this point, changing the password would be difficult. Is there any way to handle this?

partial connection string with sensitive data blocked

+7
source share
4 answers

Encode '&' as '& amp;' - ampersand is a reserved character in XML

Additional information: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

+10
source

web.config is an XML file, and the XML content must be escaped ...

Change & to & in the password field, and you're good to do it.

+5
source

Since web.config is XML, you need to avoid five special characters:

& → & ampersand, U + 0026
&lt; → < left angle bracket, less than a character, U + 003C
&gt; → > right angle bracket, greater than sign, U + 003E
&quot; → " quotation mark, U + 0022
&apos; → ' apostrophe, U + 0027

+ not a problem. I guess.

+5
source

Try to encode characters. Use &amp; for ampersand.

+1
source

All Articles