I found this weird error when I was testing a no trivial test case in my app and was not able to find out what was wrong with it.
It appears like a Json error in my asp mvc app, although the stack really doesn’t help 🙂


Basically what is happening is Json does not like to have circular reference ie. A -> B -> A
The easiest fix is to use [ScriptIgnore] in your ViewModel to tell it not to serialize object that may cause such a circulate issue.

Add the System.web.extensions reference to your viewmodel and make the elements that may cuase issue to scriptIgnore

example

By doing so now your json would look more like { Id: 3, FirstName: ‘Taswar’ }.
Also there is JSON.NET that provides [JsonIgnore] attribute if you are using json .net