Search code examples
asp.net-coreiispleskwindows-server-2019

I have published asp.net core project and getting the connection string error


I have pusblished asp.net core apllication and i am getting the error IIs 502.5 error and when i saw the logs following detail were there. Unhandled Exception: System.FormatException: Could not parse the JSON file. Error on line number '3': '"ConnectionStrings": { "DefaultConnection": "Server=.\SQLEXPRESS;Initial Catalog=twt21;User ID=twt2;Password=3Elwj5#9;"'. ---> Newtonsoft.Json.JsonReaderException: Bad JSON escape sequence: \S. Path 'ConnectionStrings.DefaultConnection', line 3, position 40.


Solution

  • You need to escape the backslash for the server in your connection string (i.e. use a double-slash) as follows:

    "ConnectionStrings": {
        "DefaultConnection": "Server=.\\SQLEXPRESS;Initial Catalog=twt21;[ENTER_CREDENTIALS_HERE]"
    }