c# - Angular 中无法读取来自 C# WebAPI 的错误 JSON 格式
问题描述
我正在尝试使用 HTTP Get 请求从 C# WebAPI 中提取数组
我使用以下代码获取列表
[HttpGet]
[Route("api/Events/GetEvents")]
public List<Event> GetEvents()
{
db.Configuration.ProxyCreationEnabled = false;
List<Event> getevents = db.Events.ToList();
return getevents;
}
这就是 Global.asx 中使用的 JSON 格式化程序的方式
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
但这是我得到的数组
{"$id":"1","$values":[{"$id":"2","Event_id":1,"Event_Name":"Soccer","Event_Date":"2021-12-02T00:00:00","Fixtures":{"$id":"3","$values":[]}},{"$id":"4","Event_id":2,"Event_Name":"Rugby","Event_Date":"2021-12-03T00:00:00","Fixtures":{"$id":"5","$values":[]}}]}
有人知道我该如何解决这个问题吗?
解决方案
推荐阅读
- c# - 你调用的对象是空的?(异常错误~ASP.NET MVC)
- javascript - 代码在本地主机上运行良好,但在托管主机提供商上运行良好 - 在互联网上搜索了 3 天,到目前为止许多尝试都是徒劳的
- c# - 在 EventHandler 中调用 this.StateHasChanged
- php - MySQL 更新查询使用等于 (=) 和 LIKE 与字母数字标准值
- c# - 如何从文件中获取缩略图
- javascript - 如何使用 reactJS 根据下拉选择更改表单字段
- tensorflow - tf.distribute.experimental.MultiWorkerMirroredStrategy() 无法正常工作
- flutter - 如何在 ListTile 中显示每个值映射?
- angular - 如何以编程方式触发 mat-table 排序?
- node.js - 节点应用程序使用 mongoose 与数百甚至数千个数据库保持连接的最佳方式是什么?