I get the following exception when posting my JSON object back to Asp.net MVC:
"The value '/Date(251071200000)/' is not valid for Date Of Birth."
Looking in Firebug there's definitely a value being posted back so I assume there's some problem in model binding. If I track the DateOfBirth property's set section the 'value' is null.
The Setup Is
C# POCO object with a DateOfBirth property as follows:
public DateTime? DateOfBirth
{
get
{
return ClientDto.Contact.DateOfBirth;
}
set
{
ClientDto.Contact.DateOfBirth = value;
}
}
The controller action sends the JSON data to the calling AJAX function as follows (Note: we've tried two options here): Option 1:
/*...extract and initialize a profile object...*/
return Json(profile, JsonRequestBehavior.AllowGet);
Option 2:
/*...extract and initialize a profile object...*/
return Json(new JavaScriptSerializer().Serialize(profile), JsonRequestBehavior.AllowGet);
We post the JSON data back from the client side as follows:
$.ajax({
url: this.editForm.prop("action"),
data: kendo.stringify(copy), //can be replaced with JSON.stringify
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (args)
{
//done
}
});