Click here to Skip to main content
15,944,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,

I am learning MVC 4 and got struck with problem. I am trying to load all menus in Layout page using partial View.

Here is the content from my Layout Page :
@{Html.RenderAction("TopMenuToLoad", "TopMenu");}

Content from my Partial View

@model  IEnumerable<OrderProcessing.Database.Menu>

       @foreach (var item in Model)
                    Html.ActionLink(item.MenuName, item.ControllerPath)


Content from my Controller of Partial View:

namespace OrderProcessing.Controllers
    public class TopMenuController : Controller
        // GET: /Menu/
        public ActionResult TopMenuToLoad()
            MVCLearningDBEntities Entities = new MVCLearningDBEntities();
            var Menus = Entities.Menus.Where(x => x.IsActive == true).ToList();
            return View(Menus);


When i run this application in debugging mode, It keeps on calling TopMenuToLoad until it throws stack overflow exception.


1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900