我在 ASP.NET MVC 5 项目中使用 MVCSiteMapProvider 4.6.7。我在mvc.sitemap
文件中有这个:
<mvcSiteMapNode title="UserManager" controller="User" action="Index">
<mvcSiteMapNode title="UserAdd" controller="User" action="Create"/>
<mvcSiteMapNode title="UserEdit" controller="User" action="Edit"
preservedRouteParameters="id"
key="User_Edit"/>
<mvcSiteMapNode title="UserView" controller="User" action="Details"/>
</mvcSiteMapNode>
我正在显示这样的站点地图路径:
<div id="breadcrumbNav">
@Html.MvcSiteMap().SiteMapPath()
</div>
当我导航到 时http://siteurl/User/Edit/2
,会显示站点地图路径,但当我导航到 时http://siteurl/User/Edit?id=2
,则不会。
删除preservedRouteParameters="id"
将扭转这种情况(站点地图显示为.../Edit?id=2
,但不是.../Edit/2
)
有没有办法让它们都工作?