1
我在客戶端的JavaScript遊戲的對象,看起來像這樣的權利被髮送到服務器之前:嵌套JSON值不具約束力MVC
這是一秒鐘後服務器端,注意所有屬性被填充,並且問題列表被填充正確數量的問題,但是每個問題的屬性都是空的,而在客戶端它們具有正確的值。
下面是機型代碼:
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。 –