-1

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 .

FBK
  • 52
  • 5
  • 20

1 Answers1

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