【发布时间】:2013-04-12 21:24:35
【问题描述】:
我在客户端 JavaScript 中有一个游戏对象,在发送到服务器之前看起来像这样:
这里是服务器端一秒钟后,请注意所有属性都已填充,并且问题列表中填充了正确数量的问题,但是每个问题的属性为空,而在客户端它们具有正确的价值观。
这是模型的代码:
public class Game
{
public Game()
{
Questions = new List<Question>(5);
}
public int GameID { get; set; }
public Guid UserID { get; set; }
public Guid CurrentGameID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public IEnumerable<Question> Questions { get; set; }
}
public class Question
{
public int ID { get; set; }
public string Text { get; set; }
public IEnumerable<int> Answers { get; set; }
public int SelectedAnswer { get; set; }
}
这是我将对象发送回服务器的方式:
// Send completed game back to server
$.post("Games/CompleteGame", currentGame, function (results)
{
// display results to user
}
【问题讨论】:
-
你能显示在 POST 中发送的原始 JSON 吗?另外,你能验证一下内容类型吗?
-
@Ek0nomik 在这种情况下我不确定如何获取原始 JSON。
标签: javascript asp.net .net asp.net-mvc-3 model-binding