I am working on a website that will post a JSON object (using jQuery Post method) to the server side.
{
"ID" : 1,
"FullName" : {
"FirstName" : "John",
"LastName" : "Smith"
}
}
At the same time, I wrote classes on the server side for this data structure.
public class User
{
public int ID { get; set; }
public Name FullName { get; set;}
}
public class Name
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
When I run the website with following code in my controller class, the FullName property doesn't get deserialized. What am I doing wrong?
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Submit(User user)
{
// At this point, user.FullName is NULL.
return View();
}