Using "& amp;" in appSettings in web.config

I am trying to save a website address in the appSettings section of the web.config file. The url has two querystring parameters at the end of the url, so I need to use the and character. When I hardcode the URL in the code file, it works if I replace "&" . In the configuration file, these letters are red. I tried both "&" and "&" in the configuration, and both of them turn red, and I cannot read them from the code file. Can someone tell me how to do this to make it work?

Thanks,

EDIT:

It looks like he hasn't read anything from appSettings. I use this line to get the settings.

 String surveyLink = ConfigurationManager.AppSettings["SatisfactionSurveyLink"]; 
+4
source share
2 answers

The problem was that I used the web.config file when I had to use the app.config file in my test project

+1
source

Given that the web.config file is XML itself, if you want the string to actually be & , you need to code it effectively twice. Try:

 & 

When XML is decoded, it is converted to & to a string, which will then be decoded again by & sounds accordingly. Having said that, it’s not entirely clear why you need & in the URL, not & if you are trying to give two separate request parameters.

+18
source

All Articles