I have a connection string which contains a password with special characters (ex. "Yaris!@#$%^&*()'?><"") and i have tried to enclose the password between " but it doesn't seem to detect the double quote from the password when I try to read the password correctly from the command line arguments added in visual studio in debug mode .
Asked
Active
Viewed 2,521 times
1 Answers
0
I hope I understood correctly. I assume you specify your connection strings in appsettings.json like below,
{
"ConnectionStrings": {
"Default": "Database=...; Server=...; Password="Yaris!@#$%^&*()'?><"""
}
}
You should use \ (escape character) before each " in your configuration. It should seem like below. Otherwise, your JSON won't be formatted correctly.
{
"ConnectionStrings": {
"Default": "Database=...; Server=...; Password=\"Yaris!@#$%^&*()'?><\"\""
}
}
You will be notice syntax highlighting in the first configuration seems wrong. Because it's doesn't know where to end the connection string value. When we add \ character before the starting quote (") it's basically ignored it.

Engincan Veske
- 1,300
- 1
- 10
- 16