views:

2048

answers:

3

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?&amp;cid=&amp;sid="/&gt;
</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.

+5  A: 

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

Eric Rosenberger
I seriously thought I had tried this. I think I missed the trailing ";" at the end. Anyways it does works so thanks for the feedback Eric.
Rob Segal
A: 

I think you should be able to use the HTML escape character (&). They can be found at http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php

ICR
A: 

Have you tried this?

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