Using Json() method on ASP.NET MVC Controller is giving me trouble - every DateTime thrown in this method is converted to UTC using server time.
Now, is there an easy way to tell ASP.NET MVC Json Serializer to stop auto-converting DateTime to UTC? As it is noted on this question reasigning each of your variable with DateTime.SpecifyKind(date, DateTimeKind.Utc) does the trick, but obviously I can't do this manually on every DateTime variable.
So is it possible to set something in Web.config and have JSON serializer treat EVERY date as if it's UTC?
Dammit, it seems that lately I'm destined to answer my own questions here at StackOverflow. Sigh, here is the solution:
Once ServiceStack.Text is installed, just override Json method in your base Controller (you do have one, right?):
It seems that this serializer by default does "the right thing" - it doesn't mess with your DateTime objects if their DateTime.Kind is Unspecified. However, I did few additional config tweaks in Global.asax (and it's good to know how to do that before you start using library):
This link helped