Why my controller returns array of empty '{}'?

Viewed 57

I'm using .NET core 5. I don't know why I am getting this kind of result from my controllers:

[
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {}
]

Here's my controller code:

[HttpGet]
public async Task<IActionResult> SalesPerson()
{
    var salesPersons = await GetAllSalesPersonsByWcf();
    List<SalesPersonDto> salesPersonResult = salesPersons.Select(
    x => new SalesPersonDto()
    {
        Id = x.Code,
        Name = x.Name,
        PhoneNo = x.Phone_No,
        Type = x.SalesPerson_Type == 0 ? "visitor" : "disturbiutor"
     }).ToList();
     return Ok(salesPersonResult);
}

in debug mode, I have the value enter image description here But I don't know why I am getting that result.

Also, I have used and that solve the problem

Content(JsonConvert.SerializeObject(salesPersonResult), "application/json");

My question is why it's happening? and what did I do wrong?

0 Answers
Related