17

My password contains special characters like '&' and VS giving error on this like Password=abcdef!@hh&held

How can I use special characters in my web.config file?

1
  • 5
    In fairness, if a person fell out of bed tomorrow and decided to do .NET programming, the web.config/app.config would be their first exposure to XML. Nothing wrong with that. It's issues like this that force people to dabble in XML in the first place.
    – user2189331
    Jul 11, 2009 at 8:07

2 Answers 2

38

Since the web.config file is an XML file, the values need to be XML encoded:

Password=abcdef!@hh&held

Note how & is replaced by &

2
  • 2
    List of characters that need to be encoded in XML: en.wikipedia.org/wiki/…
    – Dave White
    Apr 30, 2014 at 22:17
  • can a password containing equal to (=) sign is allowed in web.config? I don't see it in special character list. Mar 16, 2021 at 8:18
8

The web.config is like any other XML file, so certain characters need to be encoded.

For example, & should be written as &.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.