我有 ac# 对象(如下),我正在尝试发送到我的 javascript。
我的问题是,虽然我可以遍历列表中的项目,但我无法访问字符串属性('Period')。
在 JS 中引用对象根本不显示任何属性。在 c# 中进行 Json 编码之后,我仍然可以在将其返回给调用者之前看到该属性(将鼠标悬停在下面函数中的结果变量上):
[OutputCache(Duration = 0, VaryByParam = "None")]
public JsonResult GetRankingList() {
Response.ContentType = "text/javascript";
var user = _userService.GetUserByPrincipal(User);
// Note, we do this while the user waits as we need to make progress in repeated calls to get the compared ranking list.
_businessLogicServiceMaintenance.PerformMaintenanceSteps();
//TODO: Replace with userid (Guid)
var rankingList = _presenterService.GetRankingListForDisplay(user);
if (rankingList == null)
return Json("");
var result = Json(rankingList);
return result;
}
我到底怎么能越过这个?任何意见表示赞赏!
你的,安德斯,丹麦,
public class RankingListForDisplay : List<RankingListLine>
{
public string Period { get; set; }
}