My AJAX method returns a view model, which is a data structure serialized using JavaScriptSerializer().Serialize()
. This data includes a number of nullable DateTime?
properties.
It has come to my attention that these dates show up in JavaScript as a string in the format "/Date(1480551007625)/"
. After a little research, I figured out how to convert this to a JavaScript date.
But the problem is that if I post the data back to my AJAX methods, I get the following error:
/Date(1480551007625)/ is not a valid value for DateTime.
This error occurs even when I haven't modified that value in the view model! That is, I'm just posting back the exact same, unmodified view-model object.
How do I convert the DateTime properties in my view mode on the client side so that they can be posted back to the server and be converted back to DateTime
properties.