![](/img/trans.png)
[英]ASP.net Core 1.0 Mapping property on ApplicationUser returning null
[英]ASP.Net core - blank response when returning a JObject property
我正在使用 ASP.Net core 5.0 并希望将对象的 IEnumerable 作为 Action 方法响应返回。
这是响应类:
public class TestResponse
{
public int Id { get; set; }
public string Name { get; set; }
public Newtonsoft.Json.Linq.JObject PayLoad { get; set; }
}
这是我的动作方法:
[HttpGet]
public IEnumerable<TestResponse> TestRequest()
{
var testResponses = new List<TestResponse>();
testResponses.Add(new TestResponse { Id = 10, Name = "Name1", PayLoad = JObject.FromObject(new { Status = "Success", Message = "Working good, take care!"})});
testResponses.Add(new TestResponse { Id = 11, Name = "Name2", PayLoad = JObject.FromObject(new { Status = "Success", Message = "Working good, take care!" }) });
return testResponses;
}
当我运行它时,我看到的 PayLoad 字段的响应是:
[
{
"id": 10,
"name": "Name1",
"payLoad": {
"Status": [],
"Message": []
}
},
{
"id": 11,
"name": "Name2",
"payLoad": {
"Status": [],
"Message": []
}
}
]
为什么Status
和Message
字段为空白? 我错过了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.