How to transfer data between a controller and a view in MVC?

Our model has public DateTime date { get; set; }. In our opinion, our dates are stored in the JSON date format. Then we try to keep the updates up to date

var someObject = {};
someObject.date = JSONDate;
$.post("Controller/SaveAction", someObject, callback);

and our controller has public JsonResult SaveAction(ModelType model) { ... }, but this code breaks because it cannot convert the JSON date to a C # DateTime object.

How can I convert the JSON date to what the message will control the controller to correctly read the C # DateTime object?

+3
source share
1 answer

It is best to use the JSON.NET library where such things are already defined and (more or less) standardized.

http://json.codeplex.com/

+2
source

Source: https://habr.com/ru/post/1757388/


All Articles