3

This was suppose to an easy fix, it however proving very elusive. I keep getting the error

An error occurred while starting the application.JsonReaderException: Invalid property identifier character: {. Path '', line 2, position 2.Newtonsoft.Json.JsonTextReader.ParseProperty()FormatException: Could not parse the JSON file. Error on line number '2': '{{'.Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(bool reload) JsonReaderException: Invalid property identifier character: {. Path '', line 2, position 2.

I working on an .net core web app. I have two web apps in the same solution. I moved the appsettins file from the working Web app to the one giveing the problem and the situation is still the same. Cant figure out what I am missing

below is my appsettings.json file

{
  "Data": {
    "UserDbConn": {
      "connString": "Server=DbServer;Database=BookDB;    Trusted_Connection=True;MultipleActiveResultSets=true"
    }
  },
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Warning"
      }
    }
  }
Tee-Jay
  • 736
  • 2
  • 9
  • 28
  • Is that space between `BookDB` and `Trusted_Connection` just spaces or some kind of unreadable white-space characters? – Ignas Jun 01 '17 at 08:27
  • Thats just a formatting issue. The actual code doesnt contain that space – Tee-Jay Jun 08 '17 at 12:23
  • I solved similar error by looking in the connection string there was something like this `servername\instancename`. then I replaced it with this `servername\\instancename` and problem solved. – Hossein Narimani Rad Nov 19 '17 at 07:21

1 Answers1

4

I came across the same problem. In my case, I'd started implementing app secrets but left it halfway through. My secrets.json file was left linked but with invalid JSON.

Check your .csproj to see if a <UserSecretId> property is set under <PropertyGroup>. If it's set, BuildWebHost() will look through your secrets.json file in '%APPDATA%\Microsoft\UserSecrets\{secretId}', in addition to your appsettings.json file. An error in either file will cause the method to fail, but it won't tell you which file it is.

The solutions in my case were either to remove the <UserSecretId> property or

Steepmountain
  • 363
  • 3
  • 7