Web API突然挂起

时间:2020-02-12 12:07:24

标签: c# asp.net .net json .net-core

我的Blazor项目中有一个Web API。我有一个看起来像这样的方法:

  [HttpGet("selected/{userId}/{max}", Name = "GetItems")]
  public IList<ItemDto> GetItems(int userId, int max)
  {
      IList<ItemDto> Items = _itemsDatabaseController.GetItems(userId, max);
      return Items?.Count > 0 ? Items : null;
  }

然后我使用NSwag Studio生成了客户端代码。直到几天前一切正常,当我的API方法离开该方法后突然挂起(我在调试器中执行return和}之后,什么也没发生)。

我在某处读到,如果您在DTO中嵌套了对象,那么这可能是JSON序列化的问题。但是它的“唯一”意思是在ItemDto中我还有另外两个对象,我不明白为什么它不能序列化它(如果根本就是问题)。

有人知道为什么挂起吗?

这些是我的DTO的

public class ItemDto
{
    public int ItemId { get; set; }
    public int CompanyId { get; set; }
    public int CustomerId { get; set; }
    public int UserId { get; set; }

    public CustomerDto CustomerData { get; set; }
}

public class CustomerDto
{
    public int CustomerId { get; set; }
    public int CustomerSettingsId { get; set; }

    public ObjectDto ObjectData { get; set; }

}

public class ObjectDto
{
    public int ObjectId { get; set; }

    public string Reference { get; set; }
    public DateTime? TimeCreated { get; set; }
    public DateTime? TimeUpdated { get; set; }
}

我正在.NET Core 3.0上运行。我尚未更改JSON序列化程序,它应该是Blazor使用的默认序列化程序。

0 个答案:

没有答案