serialization - Use Date constructor invocation in serialized json from SignalR hub -


in our project, use following custom jsonconverter datetime:

public class javascriptdatetimeconverter: jsonconverter {     public override bool canconvert(type objecttype)     {         return objecttype == typeof (datetime);     }      public override void writejson(jsonwriter writer, object value, jsonserializer serializer)     {          var datetime = (datetime)value;         writer.writestartconstructor("date");         writer.writevalue(datetime.year);         writer.writevalue(datetime.month - 1);         writer.writevalue(datetime.day);         writer.writevalue(datetime.hour);         writer.writevalue(datetime.minute);         writer.writevalue(datetime.second);         writer.writevalue(datetime.millisecond);         writer.writeendconstructor();     }      public override object readjson(jsonreader reader, type objecttype, object existingvalue, jsonserializer serializer)     {         //some code     } } 

so, want use converter in signalr. here startup class:

public class startup {     public void configuration(iappbuilder app)     {         var jsonserializer = new jsonserializer();         jsonserializer.converters.add(new javascriptdatetimeconverter());         globalhost.dependencyresolver.register(typeof (jsonserializer), () => jsonserializer);         app.mapsignalr();     } } 

but when server sends json date field client, client disconnected following messages:

signalr: stopping connection.
signalr: closing websocket.
signalr: fired ajax abort async = true.
signalr: stopping monitoring of keep alive.

what doing wrong?


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -