解决方法:在Startup的ConfigureServices方法里加上下面的红色部分。
public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1). AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); }