I wanna to have dynamic categories in my web site, Adding category in Admin area and show as a partialView in main page , it is clear that I should cache that , my category action is like this :
public ActionResult Category()
{
var category = _categoryRepository.GetAllCategory();
return PartialView(category);
}
and my partialView is :
@model IEnumerable<Blog.Domain.Model.Category>
@{
ViewBag.Title = "Category";
Layout = null;
}
<div>
@foreach (var item in Model)
{
<ul>
@Html.DisplayFor(x => item.Name)
</ul>
}
</div>
I’m not sure about above code and also have no idea about how to cache Category , please someone help me about that,thanks
Not sure if this answers you question or not but to assign them a link just use Html.ActionLink() then have an action that take the selected category id as a parameter and loads a detailed view of the Category.