How can I add an ampersand for a value in a ASP.net/C# app config file value

Rob Segal picture Rob Segal · Dec 17, 2008 · Viewed 102.9k times · Source

I've got a C# program with values in a config file. What I want is to store ampersands for an url value like...

<appSettings>
  <add key="myurl" value="http://www.myurl.com?&cid=&sid="/>
</appSettings>

But I get errors building my site. The ampersand is not allowed. I've tried various forms of escaping the ampersands to no avail. Anyone know of the correct form to do this? All suggestions are welcome.

Answer

Eric Rosenberger picture Eric Rosenberger · Dec 17, 2008

Use "&amp;" instead of "&".