Jul 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: ,

Comments

1.
ballon anniversaire ballon anniversaire France says:

Hello Guru, what entice you to post an article. This article was extremely interesting, especially since I was searching for thoughts on this subject last Thursday.

2.
trasloco milano trasloco milano United States says:

nice post. .thanks for sharing

3.
watch movies online free watch movies online free United States says:

I like watching movies online, it is way cheaper than going to the theaters.

4.
Stanley Stanley Japan says:

This is interesting, post about app config more often!

5.
safety training safety training United States says:

Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading