Could Not Parse the Json File ,Error in Progam.Cs ASP.NET Core

My .NET Core 5.0 web application is not working after publishing it. Error "Unhandled exception. System.TypeInitializationException: "

Your connection string is escaped improperly.

Change this

    "ConnectionString": "Server=1**1\Manageengine;Database=ServiceDesk;Trusted_Connection=True;User ID=ad-***\tmsdb.****;Password=$***"

to this

    "ConnectionString": "Server=1**1\\Manageengine;Database=ServiceDesk;Trusted_Connection=True;User ID=ad-***\\tmsdb.****;Password=$***"

You need an extra \ for two parts of that string. The \M and the \t need to be \\M and \\t respectively.

JSON Parsing Issue - 'S' is an invalid escapable character within a JSON

In your ConnectionStrings. DefaultConnString field, you're escaping S (before SQLExpress;). As the error suggests, you can't do that.

You can fix this by adding another escape character (backslash, \) in front of the pre-existing one. Backslashes are escapable characters and the end result will be the wanted one, you'll get one backslash in that position.

Upgraded to ASP.NET Core 3.1, getting error about System.Text.Json

The trick that solves 90% of the issues since Visual Studio 2002 ;-)

manually delete all bin and obj folders in your solution.

Error parsing JSON for network server name

It's hard to know exactly what your problem is without seeing the exact error message, but this sequence of characters at the beginning of your string looks wrong:


Since \ is used to escape the following character, then \" will be interpreted as " and \\ will be interpreted as \. This leaves \E which is not a valid escape sequence. I also don't think you need \" at the beginning or end of your string, unless the code that uses this value expects the string to be "wrapped" with double quotes.

Try the following, and see if that resolves your parsing error:

"ExportLocation": "\\\\\\filefolder\\subfolder\\"

More information on other valid escape sequences can be found here.

Related Topics

Leave a reply