Reputation: 10591
I am trying to interact with an ASP.NET MVC controller action using a ServiceStack JsonServiceClient. The default serialization behavior of DateTime objects does not seem to be compatible with what MVC supports, is there any way to alter client's DateTime serialization behavior?
Upvotes: 2
Views: 689
Reputation: 5101
I believe the ServiceStack DateTime serialization can be controlled by setting the ServiceStack.Text.JsConfig.DateHandler
property.
Upvotes: 2
Reputation: 1038730
is there any way to alter client's DateTime serialization behavior?
In ASP.NET MVC there are 2 aspects: model binding JSON requests and sending JSON responses. Both use the built-in .NET JavaScriptSerializer
.
In order to alter the model binder you could write a custom ValueProviderFactory
.
For response JSON objects you could write a custom ActionResult instead of using the built-in Json method as shown in this thread
.
If you want to alter the behavior on the client then you could use what @AlexD suggested in his answer.
Upvotes: 1