I struggled with this problem for a while. I am trying to send an object to a client. After the client updates the object, I would like to send it back to the server and save it in my database. The first part works great. However, when I send it back, all dates are mixed up and start during the year 0001. I assume that since it cannot deserialize the date. Howe can I publish a json object with a date property and deserialize it to a type on a server with asp.net mvc 3?
Group
public class Group
{
public Group();
public string CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public string Description { get; set; }
public string Name{ get; set; }
public string Status { get; set; }
public string UpdatedBy { get; set; }
public DateTime UpdatedOn { get; set; }
}
and
public JsonResult updateGroup(Group group)
{
var result = Repository.updateGroup(group);
return Json(result, JsonRequestBehavior.AllowGet);
}
and on the client I received
$.ajax({
url: '../updateGroup',
type: 'POST',
data: JSON.stringify(group),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function(){ success(); }
});
source
share