I've got a very simple Action on my Controller that's attempting to return my XmlSiteMap as a JsonResult:
public ActionResult Index()
{
var nodes = SiteMap.Provider.RootNode;
return new JsonResult()
{ Data = nodes, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
However, when I call the Action, an InvalidOperationException is thrown:
"A circular reference was detected while serializing an object of
type 'System.Web.SiteMapNode'."
Is there a way to Json serialize a SiteMap, or indeed any object that has children of the same type?