2

我正在使用 mvcsitemap 为我正在开发的 web 应用程序创建菜单、子菜单和面包屑。我在 xml 配置中使用 preserveroutevalues 以便在呈现链接时移动我的(许多)参数。当用户开始使用查询参数时,菜单/子菜单/面包屑会在某些页面加载后消失。这并不一致,我不能一直重现它,但它发生得太频繁了。

我的路线

routes.MapRoute(
                    name: "ForwardCurveDefault",
                    url: "forward-curve/{commoditycode}/{selectedyear}-{selectedmonth}-{selectedday}",
                    defaults: new {
                        controller = "ForwardCurve", action = "index",
                        selectedyear = default(DateTime).Year,
                        selectedmonth = default(DateTime).Month,
                        selectedday = default(DateTime).Day,
                        commoditycode = "none"
                    }
                );
routes.MapRoute(
                    name: "Consumption",
                    url: "consumption/{commoditycode}/{managedcompanyid}/{entityid}/{startyear}-{startmonth}-{startday}/{endyear}-{endmonth}-{endday}",
                    defaults: new {
                        controller = "Consumption", action = "Index",
                        // begining of current month.
                        startyear = default(DateTime).Year,
                        startmonth = default(DateTime).Month,
                        startday = default(DateTime).Day,
                        // end of current month.
                        endyear = default(DateTime).Year,
                        endmonth = default(DateTime).Month,
                        endday = default(DateTime).Day,
                        commoditycode = "none",
                        managedcompanyid = 0,
                        entityid = 0,
                    }
                );

 routes.MapRoute(
                    name: "Budget",
                    url: "budget/{commoditycode}/{managedcompanyid}/{entityid}/{startyear}-{startmonth}-{startday}/{endyear}-{endmonth}-{endday}",
                    defaults: new {
                        controller = "Budget", action = "Index",
                        // begining of current month.
                        startyear = default(DateTime).Year,
                        startmonth = default(DateTime).Month,
                        startday = default(DateTime).Day,
                        // end of current month.
                        endyear = default(DateTime).Year,
                        endmonth = default(DateTime).Month,
                        endday = default(DateTime).Day,
                        commoditycode = "none",
                        managedcompanyid = 0,
                        entityid = 0,
                    }
                );

我的站点地图

<mvcSiteMapNode title="Data Management" controller="ForwardCurve" action="Index" key="DataManagement" preservedRouteParameters="commoditycode,selectedyear,selectedmonth,selectedday">
  <mvcSiteMapNode title="Forward curves" controller="ForwardCurve" action="Index" key="forwardcurve" preservedRouteParameters="commoditycode,selectedyear,selectedmonth,selectedday"/>
  <mvcSiteMapNode title="Consumption" controller="Consumption" action="Index" key="consumption" preservedRouteParameters="commoditycode,managedcompanyid,entityid,startyear,startmonth,startday,endyear,endmonth,endday"/>
  <mvcSiteMapNode title="Budget" controller="Budget" action="Index" key="budget" preservedRouteParameters="commoditycode,managedcompanyid,entityid,startyear,startmonth,startday,endyear,endmonth,endday"/>
</mvcSiteMapNode>

我得到了一份不错的菜单。在来回访问不同的查询值之后,我最终进入了一个具有有效 URL 且没有菜单的页面。我可以看到我的 currentNode 为空。

4

1 回答 1

0

你用4.0 版检查过吗?节点匹配逻辑有了一些重大改进。

于 2013-08-14T14:54:14.743 回答