Take the 2-minute tour ×

I've create a custom configuration section in my web.config file for my 3.5 web application. The custom configuration contains special characters listed below.

  <add Key="2" String="â€"/>
  <add Key="3" String="148"/>
  <add Key="4" String="!X"/>
  <add Key="5" String="¡§"/>
  <add Key="6" String="¡¦"/>
  <add Key="7" String="¡¨"/>
  <add Key="8" String="’" />
  <add Key="9" String="–" />

I currently have the xml type of the web.config defined as below.

<?xml version="1.0"?>

This works fine in one development environment, but when I migrate the application to another environment I get an xml parsing error on the string for Key 2. When I replace all the string definitions for each config entry with standard alpha chars, the application works fine. Is there a way to enforce the XML to be read the same way? I have looked into the encoding attribute for the xml definition tag, just not positive what to set it to. Any guidance would be well appreciated. Thanks in advance.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Are you typing these into your web.config file manually? Can't you just HTML-encode your string values?

share|improve this answer
It's XML, not HTML. Numeric entity codes would work, but not other HTML entities. –  tdammers Dec 29 '10 at 16:34
No, I did't type those values in manually. I used the HTML-encode solution to fix my issue and it worked out well. Thanks. –  tim_bo05 Dec 29 '10 at 20:05

I recommend setting the encoding to "utf-8". Make sure the file is also actually saved as utf-8.

share|improve this answer
Tried this and still no luck. Ended up going with Jonathan solution so I didn't have to rely on the encoding type. –  tim_bo05 Dec 29 '10 at 19:59

Your Answer


