4

I have a web.config file, in connection string attribute, I have an '&' in password which creates error in parsing web.config file.

code:

<connectionStrings>
    <clear/>

    <add name="FamefaceDB" connectionString="Data Source=ec2-204-236-162-54.us-west-1.compute.amazonaws.com;Initial Catalog=famefacedb;User ID=Administrator;Password= t2kfPcn6?D& "/>
  </connectionStrings>

The '&' in password is illegal and says hexadecimal value is illegal in XML file.

Is there any solution to this?

Khushbu
  • 205
  • 2
  • 5
  • 19
  • Check this http://stackoverflow.com/questions/7248958/which-are-the-html-and-xml-special-characters – Noel May 23 '13 at 05:43

1 Answers1

9

XML is XML and web.config must be valid XML - a "literal" & must be written as &amp;1

Compare with the correct entity encoding:

<add connectionString="..;Password=t2kfPcn6?D&amp;"/>

1See Which are the HTML, and XML, special characters? (linked by Noel in a comment) for the gritty details.

Community
  • 1
  • 1
user2246674
  • 7,621
  • 25
  • 28