Is it possible to return a SiteMap as a JsonResult?
Posted
by Paul Suart
on Stack Overflow
See other posts from Stack Overflow
or by Paul Suart
Published on 2010-03-18T09:58:50Z
Indexed on
2010/05/10
5:08 UTC
Read the original article
Hit count: 279
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?
© Stack Overflow or respective owner