I have created a controller with following action. Passing list of categories using viewdata as below
public ActionResult Home()
{
ViewData["categories"] = db.Categories.ToList();
return View();
}
I want to render the list of categories using partial view. so partial view is created with following markup
@using test.Models
@{
ViewBag.Title = "mnuCategories";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Browse Categories</h2>
@foreach(Category c in (IEnumerable<Category>)ViewData["categories"])
{
@c.CategoryName
}
i am rendering this partial view on home page using
@Html.Partial("mnuCategories")
but when i am running the application it given me "stackoverflow excception"
Layout = "~/Views/Shared/_Layout.cshtml";