Could not parse the JSON file ,Error in Progam.cs asp.net core

后端 未结 11 1057
星月不相逢
星月不相逢 2021-02-07 19:42

I have some issues with the program.cs file, with the version of ASP.NetCORE 2.0

Here\'s my code

     public class Program
{
    public static void Main(st         


        
相关标签:
11条回答
  • 2021-02-07 20:34

    In my case I had faced this issue as I had added User Secret to my solution and later removed all of its content including { }. Please make sure the content in the file is with proper JSON format. Or try providing an empty object { } to the file if no information needed from it.

    0 讨论(0)
  • 2021-02-07 20:34

    Same problem and solved by removing <UserSecretsId> </UserSecretsId> from *.cproj.

    It was a bad user secret configuration

    0 讨论(0)
  • 2021-02-07 20:37

    in m case I put extra { right before (above) "ConnectionStrings" : in appsettings.json

    I copied this from another file and assumed that "ConnectionStrings" : must inside a curly braces {}

    before

    ...
    },
    {  //<-- this one the culprit
        "ConnectionStrings": {
          "Dapper": "Server=.;Database=Dapper;Trusted_Connection=True;"
        },
    

    after

    ...
    },
        "ConnectionStrings": {
          "Dapper": "Server=.;Database=Dapper;Trusted_Connection=True;"
        },
    
    0 讨论(0)
  • 2021-02-07 20:39

    I had this problem and the reason is that for some reason Visual Studio saves files with some invisible metadata that goes before the text therefore JSON reader cannot parse it.

    You need to File -> Save As -> (Choose UTF-8 Without BOM).

    0 讨论(0)
  • 2021-02-07 20:39

    I had the same problem.
    I found that this problem seemed to have been caused by my appsettings.json file.
    I copied a version from another place to solve this problem.

    0 讨论(0)
提交回复
热议问题