Tem 27 2009

How can I use ampersand in AppSettings value - app config file

Category: ASP.NETLatif @ 00:28

Hi,

If you want to put an & (ampersand) character into the value attribute of a key in the appSettings part of the XML .config file(web.config, app.config etc.)

Let's say, you have param like following, (The error will occur if you use like this)

   <appSettings>

    <add key="MyUrl" value="http://localhost:8080/mysite/summarize?name=testPDF&format=pdf"  />

  </appSettings>

Solution : 

   <appSettings>

    <add key="MyUrl" value="http://localhost:8080/mysite/summarize?name=testPDF&amp;format=pdf"  />

  </appSettings>

use &amp; instead of &

Cause :

It is because of XML rules that the & character is the token for beginning of a reference. For more information http://www.w3schools.com/xml/xml_cdata.asp

 tot ziens...

 

Tags: ,