1

When using Clients.All.someMethod(myData) in SignalR, how can you intercept the data that is send back to the client? I know MVC is using a default JavascripDeserializer. Is this serializer also used when sending data back to the client using SignalR?

What I want in the end, is to convert DateTime C# properties to my own custom format in Json.

Can someone help me / explain to me how to do this?

Edit:

myData can be just a plain object with a DateTime property, but it is also possible that it is a list of integers or dates. It actually doesn't matter, I just want to know how I can interrupt the conversion from C# to Json when using SignalR.

Martijn
  • 24,441
  • 60
  • 174
  • 261
  • Maybe this http://stackoverflow.com/questions/12589159/signalr-and-serializing-object-array can give you some clue... – Youp Bernoulli Jan 09 '15 at 08:31
  • I don't really understand your problem. I assume that "myData" is some kind of list of some objects with dates. You can prepare the correct format before sending it to clients. Or by using javascript you can convert on client side the dates... you don't know how to read data on client side or what? – Eru Jan 09 '15 at 08:34
  • @YoupTube Thanks, I wasn't aware that SignalR uses it's own serialize / deserialize process – Martijn Jan 09 '15 at 08:48

1 Answers1

0

SignalR is using JSON.NET for serialization so you can decorate your datetime property with non default datetime formatter or even create your own http://james.newtonking.com/json/help/index.html

Custom serializer is not possible: registering JavaScriptSerializer with signalr

Martin Vich
  • 1,062
  • 1
  • 7
  • 22