Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web.config file with appSetting Value containing "&" not being parsed

    <appSettings>
    <add key="myKeyName" value="DFG&y:yd%yeZ" />
  </appSettings>

I have a web.config file in an ASP.NET MVC application. In my appSettings section, i have a key whose value contains a character that makes the web.config invalid.

The character is the "&" in value="DFG&y:yd%yeZ", if i remove it, the app works fine, when i put it back i get the error below.

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred while parsing EntityName. Line 25, position 61.

And my key below is highlighted in red.

 <add key="myKeyName" value="DFG&y:yd%yeZ" />

Is the "&" prohibited in the a web.config's appSettings key Value?

like image 634
StackTrace Avatar asked Oct 15 '25 08:10

StackTrace


1 Answers

You need to replace the special char "&" by:

&amp;

Here is a list of special chars

like image 64
Andrew Paes Avatar answered Oct 18 '25 01:10

Andrew Paes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!