I’m trying to serialize a virtual directory to json but I get a ArgumentException: RecursionLimit exceeded because of the hierarchical directories. Is it possible to limit the serializer to one level or so? Stack trace here: http://pastebin.com/raw.php?i=nByECbCs
var directory = HostingEnvironment.VirtualPathProvider.GetDirectory(path);
return Json(directory, JsonRequestBehavior.AllowGet);
The JSON serializer doesn’t support recursive objects and you cannot limit to a given level. I would recommend you extracting only the information you need into a view model and then JSON serialize this specific model instead of using the
VirtualDirectoryclass which contains a multitude of properties and methods.