I ran into this particular issue while using SignalR, but it would happen in any case where you are serializing data to JSON using Newtonsoft’s JSON.NET library. I was finding that properties on my C# object were clearly marked with the [ScriptIgnore] attribute were still being serialized, which was sending unnecessary data down to the browser.
1 | [ScriptIgnore] |
The answer turned out to be simple: SignalR uses JSON.NET behind the scenes to do the heavy serialization lifting, and JSON.NET looks for the [JsonIgnore] attribute instead.
1 | [JsonIgnore] |
If only all of my annoying little bugs were this easy to solve!
No comments:
Post a Comment