我想使用 MvcSiteMap 来定义我的控制器和操作的站点地图,让我生成面包屑和菜单。
我尝试使用下面的装饰器以编程方式添加节点,但不幸的是它不会使我的树像我想要的那样。
[MvcSiteMapNodeAttribute(Title = "Home"]
[MvcSiteMapNodeAttribute(Title = "Services", ParentKey = "Home")]
[MvcSiteMapNodeAttribute(Title = "Service detail", ParentKey = "Services")]
[MvcSiteMapNodeAttribute(Title = "Edit", ParentKey = "Service detail")]
我如何装饰我的行为以确保孩子/父母关系按照我的意愿进行?
[HandleError]
public class HomeController : Controller
{
// Home
public ActionResult Index ()
{
return View();
}
}
[HandleError]
public class ServiceController : Controller
{
// Home > Services
public ActionResult Index ()
{
return View();
}
// Home > Services > Service detail
public ActionResult Details (int id)
{
return View();
}
// Home > Services > Service detail > Edit
public ActionResult Edit (int id)
{
return View();
}
}