You haven't properly encoded the ampersands in your URI. Remember that app.config
is an XML file, so you must conform to XML's requirements for escaping (e.g. &
should be &
, <
should be <
and >
should be >
).
In your case, it should look like this:
<appSettings>
<add
key="fooUriString"
value="https://foo.bar.baz/download/DownloadStream?id=5486cfb8c50c9f9a2c1bc43daf7ddeed&login=null&password=null"
/>
</appSettings>
But in general, if you wanted to store a string that looked like "I <3 angle bra<kets & ampersands >>>"
then do this:
<appSettings>
<add
key="someString"
value="I <3 angle bra<kets & ampersands >>>"
/>
</appSettings>
void StringEncodingTest() {
String expected = "I <3 angle bra<kets & ampersands >>>";
String actual = ConfigurationManager.AppSettings["someString"];
Debug.Assert.AreEqual( expected, actual );
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…