Escape & in App.config

.NetApp Config

.Net Problem Overview


I have the following piece of config in my App.config file:

<add key="ConnectionString" 
     value="INITIAL CATALOG=myDatabase;DATA SOURCE=myServer;User ID=myUser;Password=!&myPass99;"/>

The above connection string is rejected by Visual Studio intellisense. It says entity myPass99 not defined. The problem is caused by the & in the password.

How do I escape it?

.Net Solutions


Solution 1 - .Net

Escape the ampersand by using &amp; in place of the &

As an FYI, see here for further characters: https://stackoverflow.com/questions/1091945/where-can-i-get-a-list-of-the-xml-document-escape-characters

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiondeveloper747View Question on Stackoverflow
Solution 1 - .NetjglouieView Answer on Stackoverflow