这是我对面包屑的部分看法,现在我的问题是,当我粘贴不同菜单的url时,面包屑不会更改,请保留旧的URL面包屑。
@{
IEnumerable<DO.Domain.Authorize.MenuMaster> menus = ViewBag.Menus;
int menuID = ViewBag.MenuID;
DO.Domain.Authorize.MenuMaster currentMenu = menus.Where(p => p.MenuID == menuID).FirstOrDefault();
List<DO.Domain.Authorize.MenuMaster> breadcrumbsList = new List<DO.Domain.Authorize.MenuMaster>();
if (currentMenu != null)
{
breadcrumbsList.Add(currentMenu);
while (currentMenu.FK_MenuID != null)
{
currentMenu = menus.Where(p => p.MenuID == currentMenu.FK_MenuID).FirstOrDefault();
if (currentMenu == null) {
return;
}
breadcrumbsList.Add(currentMenu);
}
breadcrumbsList.Reverse();
}
string name = ViewContext.RouteData.Values["action"].ToString();
}
<div class="top-menu-breadcrumb">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="@Url.Action("Index", "Home", new { area = ""})">Home</a></li>
@foreach (var item in breadcrumbsList)
{
<li class="breadcrumb-item">
@if (item.ActionName != null)
{
<a href="@Url.Action(item.ActionName, item.ControllerName, new { area = item.AreaName })">
@item.MenuName
</a>
}
else
{@item.MenuName}
</li>
}
@if (!name.IsEmpty())
{
<li class="breadcrumb-item">@name</li>
}
</ol>
</nav>
</div>
对此有何建议? 谢谢