WebApi Json.NET custom date handling

Change your setting set up code like this:

JsonMediaTypeFormatter jsonFormatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
JsonSerializerSettings jSettings = new Newtonsoft.Json.JsonSerializerSettings()         
{
    Formatting = Formatting.Indented,
    DateTimeZoneHandling = DateTimeZoneHandling.Utc
};
jSettings.Converters.Add(new MyDateTimeConvertor());
jsonFormatter.SerializerSettings = jSettings;

In your code you are just changing local variable value.

Leave a Comment