An unhandled exception of type 'System.StackOverflowException' occurred in Unknown Module.

by sunil ravulapalli /14. June 2011 21:37 /asp.net-mvc /Comments (1)

I go this error recently:

"An unhandled exception of type 'System.StackOverflowException' occurred in Unknown Module."

I narrowed it down to the Html.Action( Html.RenderAction ) call in _Layout.cshtml.

The Html.Action in _Layout.cshtml looked like this:

@{ Html.Action("List", "Categories"); }

My controller method looked like this:

public ActionResult List()
{
            List categories = categoriesRepository.Categories.ToList();
            List navLinks = new List();

            foreach (Category cat in categories)
                navLinks.Add(makeLink(cat));

            return View(navLinks);
}

Turns out the proper way to design this is to do the following:

here
blog comments powered by Disqus