Is it possible to return a pre-encoded JSON string in a SignalR hub method?
In an MVC project, I have a method on a hub similar to this: public string Foo() { return DoCrazyThingThatReturnsJson(); } Unfortunately SignalR (or something) takes the encoded JSON string and happily encodes it, then returns it, so browser be like LOLWTF. Is there a way to skip this second encoding? Looking at this here : We assume that any ArraySegment is already JSON serialized it seems like something like this may work (note that I haven't tried it, so no promises): string jsonString = ...; // your serialized data var jsonBytes = new ArraySegment<byte>(Encoding.UTF8.GetBytes(jsonString));