Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'&' in password illegal character in web.config file

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?

like image 901
Khushbu Avatar asked Jan 13 '23 07:01

Khushbu


1 Answers

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.

like image 134
user2246674 Avatar answered Feb 11 '23 11:02

user2246674