web.config appSettings Store value with & character

M

Max

hi

i have stored my connction string in web.config as we do usually. code
of web.confing is given below.

check the password field contain "&" character. now when i run my
application it gives error because value of ConnectionString is breaked
at "&".

So how to store value in web.config that contain "&" character, if any
one know the solution pls let me know. code of web.config and error
given by visual studio is given below.

<configuration>
<appSettings>
<add key="ConnectionStri

ng" value="server=localhost;user id=mas;password=mas&2003;database=CMS"
/>
</appSettings>
....
....
and so on </configuration>

Error Give by VS 2003
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: Reference to undeclared parameter entity, 'max'.

Source Error:

[No relevant source lines]


Source File: D:\dnSource\HOMEAPPS_mahesh\web.config Line: 0
 
F

Frans Bouma [C# MVP]

Max said:
hi

i have stored my connction string in web.config as we do usually. code
of web.confing is given below.

check the password field contain "&" character. now when i run my
application it gives error because value of ConnectionString is
breaked at "&".

So how to store value in web.config that contain "&" character, if
any one know the solution pls let me know. code of web.config and
error given by visual studio is given below.

<configuration>
<appSettings>
<add key="ConnectionStri

ng" value="server=localhost;user
id=mas;password=mas&2003;database=CMS" />
</appSettings>
...
...
and so on </configuration>

Error Give by VS 2003
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: Reference to undeclared parameter entity, 'max'.

Source Error:

[No relevant source lines]


Source File: D:\dnSource\HOMEAPPS_mahesh\web.config Line: 0

try replacing & with &amp;
The xml gets deserialized into an XMLDocument, which converts these
kind of characters back to readable chars.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top