I have a knockout/mvc3 application. I am passing the date back to a controller.
controller
public ActionResult PackageUpdate(Package updatePackage){
\\do some stuff but dates are set to zero?
}
view model and save method
var Package = function (data) {
self = this;
self = ko.mapping.fromJS(data);
self.save = function(){
$.ajax({
url: '/MediaSchedule/PackageUpdate',
data:ko.toJSON({ updatePackage: self })
}).success(function (results) {
console.log(results);
}).error(function (er) {
console.error('Ah damn you broke it.')
console.log(er);
});
}
return self;
}
Json Being passed.
{"updatePackage":{"Id":"82e3bc7e-27b8-49c2-b1fa-1ee2ebffbe66","Name":"28a38","SecondaryName":"è€å我è¦é’±","IsLocked":true},"DateCreated":"/Date(1357650000000+1100)/","DateStart":"/Date(1365080400000+1100)/","DateEnd":"/Date(1365516000000+1000)/"}
ID, name and other properties are coming through but the date is being reset to {1/1/0001 12:00:00 AM}. My assumption is because it is not being deserialised it is setting a min date. Question: How do I correctly deserialise my date.