ASP.NET Web API Date format in JSON does not serialise successfully

后端 未结 2 1789
不知归路
不知归路 2020-12-06 00:28

All,

We are using ASP.NET Web API where we have a REST based service with JSON for the payload. If I pass the following Date as a string e.g

sampleO         


        
2条回答
  •  借酒劲吻你
    2020-12-06 01:20

    Just set globalization in web.config:

    
    

    and then, in Global.asax.cs > Application_Start, set JsonFormatter to use the current culture:

    var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
    json.SerializerSettings.Culture = System.Globalization.CultureInfo.CurrentCulture;
    

提交回复
热议问题