错误演示
返回码:500
错误信息: Serialization and deserialization of ‘System.Type’ instances are not supported. Path: $.Columns.DataType.(不支持“System.Type”实例的序列化和反序列化)
解决办法
安装Nuget包:Microsoft.AspNetCore.Mvc.NewtonsoftJson(注意版本 7.0适用 core7 ,6.0适用 core6)
在Program.cs添加代码: builder.Services.AddControllers().AddNewtonsoftJson();
注意:.netcore6 之后 startUp.cs 的配置文件被整合到了 Program.cs 所以我上面才会在Program.cs里面添加代码,如果是6之前,则在startUp.cs的ConfigureServices方法里面添加Services.AddControllers().AddNewtonsoftJson();
问题解决,成功返回DataTable