AndreyAkinshin / knockout-mvc

Power of Knockout.js for ASP.NET MVC
http://knockoutmvc.com
203 stars 125 forks source link

DateTime lost after executeOnServer #11

Open rnikitin opened 11 years ago

rnikitin commented 11 years ago

I tried to work with Model, containing Data.

The format I received from server with first request: /Date(1354656075282)\/"} While executing it sends with correct format. But when it returned back from server side: /Date(-62135596800000)/

I cheched with debugger - on server side the field already lost. So, it could be a problem somewhere in KnockoutUtilities.ConvertData.

Could somebody reproduce this issue?

BTW, please send to NuGet fresh version of the library :)

AndreyAkinshin commented 11 years ago

Hi, rnikitin.

Now best way to use Date with JSON is use string in model and parse it on server. But I'll try to study your problem more closely. The new NuGet-package will be soon.

rnikitin commented 11 years ago

That looks a way I fixes this, but I used an int to store milliseconds.

BTW, found, that Serialization and Deserialization pretty slow and with 20-30 entities it took about 1 second to serialize -> deserialize -> serialize to client again.

Tried to replace this serialization to Json.Net - no luck. I think, that ConvertData, which uses reflections, isn't too fast. Is there any way to rewrite it or to throw it away?

AndreyAkinshin commented 11 years ago

Hmm... Ok, I will research this question.

TecNic commented 10 years ago

it's not an issue with KnockoutUtilities but a javascript one. as Andrey said, the best way to avoid this is to convert it to string

rnikitin commented 10 years ago

Anyway the best way is to use proper serializer/deserializer like json.NET.