我有一个简单的方法DateTimeNow,它返回DateTime.Now。
在Visual Studio中启动项目时,我进入/ metadata页面,我可以看到列出的方法:
Operations:
DateTimeNow XML JSON
点击XML链接时,我得到:
<DateTimeNowResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyServices.DTO">
<Result>0001-01-01T00:00:00</Result>
</DateTimeNowResponse>
但是当点击JSON链接时,我得到:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The added or subtracted value results in an un-representable DateTime.
Parameter name: value
我开始创建项目,如http://www.servicestack.net/ServiceStack.Hello/
所示我使用的是版本3.9.46:
ServiceStack.3.9.46\lib\net35\ServiceStack.dll
ServiceStack.3.9.46\lib\net35\ServiceStack.ServiceInterface.dll
ServiceStack.Common.3.9.46\lib\net35\ServiceStack.Common.dll
ServiceStack.Common.3.9.46\lib\net35\ServiceStack.Interfaces.dll
ServiceStack.Text.3.9.46\lib\net35\ServiceStack.Text.dll
Visual Studio 2012项目使用.NET Framework 4.5
答案 0 :(得分:2)
JSON日期使用JavaScript Date对象,该对象表示日期为自1970-01-01 00:00:00 UTC以来的秒数。您正在转换之前的时间,因此无法表示。