MVCSiteMapProvider Breadcrumb和SiteMapPreserveRouteData随第二个项目
本文关键字:第二个 项目 SiteMapPreserveRouteData Breadcrumb MVCSiteMapProvider | 更新日期: 2023-09-27 18:19:34
我有一个MVC项目,我正在用MVCSiteMapProvider实现一个breadcrumb。
我的MVC.站点地图如下:
<mvcSiteMapNode title="Index" controller="Index" action="Index" key="Index">
<mvcSiteMapNode title="Parent" controller="Parent" action="View" key="Parent" >
<mvcSiteMapNode title="Child" controller="Child" action="View" />
</mvcSiteMapNode>
</mvcSiteMapNode>
我已将添加到布局视图(_L)
@Html.MvcSiteMap().SiteMapPath()
当我返回到父项时,我需要保留参数以检索正确的项。为此,我在View操作中添加了注释SiteMapPreserveRouteData:
[SiteMapPreserveRouteData]
public ActionResult View(Guid id)
现在,我可以使用我的面包屑导航了。
问题是它只适用于第一个项目。当我更改项目时,面包屑会消失。。。
样品:我导航到Parent p2->Child c1,在返回到Index并选择Parent p1之后,父级的View页面不会显示breadcrumb。
如果我删除了注释SiteMapPreserveRouteData,但面包屑丢失了id,则不会发生这种情况。。
我现在在做什么?有什么想法吗?
感谢
问题很可能是您的方法。我根本不建议使用SiteMapPreserveRoutData——这是一种暴力,更重要的是,它的设计方法有缺陷。
我创建了一个帖子,深入了解如何跟踪用户在网站地图中的位置-如何让MvcSiteMapProvider记住用户的位置。了解帖子中的信息是制作不会消失的面包屑痕迹的关键。