JavaScriptSerializer js = new JavaScriptSerializer();
var result = js.Serialize(data);
This is my model:
public class EmployeeDetailsDTO : IEmployeeDetailsDTO
{
public int EmployeeId { get; set; }
public string EmployeeName { get; set; }
public Datetime date{get;set;}
}
I Passed this serialized object into webapi from an MVC application through the body of the request.But in my webapi controller the date become one less(11-02- 2018 is changed into 10-02-2018).
but when i used this code the problem is solved.Did anybody know what is happening?
var data = JsonConvert.SerializeObject(data);
webapi is deserializing the data for me.so explicitly writing (.ToLocalTime();) is not possible in this case.