Model view controller MVCSiteMapProvider不';不显示站点映射路径

Model view controller MVCSiteMapProvider不';不显示站点映射路径,model-view-controller,asp.net-mvc-5,sitemap,mvcsitemapprovider,Model View Controller,Asp.net Mvc 5,Sitemap,Mvcsitemapprovider,我有一个简单的网站地图: <mvcSiteMapNode title="Projects" controller="Projects" action="Index"> <!--This wraps the entire site since Projects Index is the homepage--> <mvcSiteMapNode title="Projects" controller="Projects" action="Index">

我有一个简单的网站地图:

<mvcSiteMapNode title="Projects" controller="Projects" action="Index"> <!--This wraps the entire site since Projects Index is the homepage-->
    <mvcSiteMapNode title="Projects" controller="Projects" action="Index">
      <mvcSiteMapNode title="Project" controller="Projects" action="Details">
        <mvcSiteMapNode title="Session" controller="Session" action="DetailsNew" />
        <mvcSiteMapNode title="Edit Session" controller="Session" action="Edit" />
      </mvcSiteMapNode>
    </mvcSiteMapNode>
    <mvcSiteMapNode title="My Account" controller="Account" action="ChangePassword" />
    <mvcSiteMapNode title="Admin" controller="Admin" action="Index" >
      <mvcSiteMapNode title="Create User" controller="Admin" action="AddUser" />
      <mvcSiteMapNode title="Manage Users" controller="Admin" action="Users" />
    </mvcSiteMapNode>
  </mvcSiteMapNode>


当我将
@Html.MvcSiteMap().SiteMapPath()
放在我的项目详细信息页面上时,没有显示任何内容。想法?

当您添加自定义路由值(除“区域”、“控制器”或“操作”之外的其他值)时,您需要明确指定如何匹配该值

默认情况下,您需要为每个可能的路由键值创建一个节点。例如,如果您有一个名为“id”的路由密钥,并且有id为“1”、“2”和“3”的记录,则需要为每个id创建一个节点

<mvcSiteMapNode title="Project 1" controller="Project" action="Details" id="1">
<mvcSiteMapNode title="Project 2" controller="Project" action="Details" id="2">
<mvcSiteMapNode title="Project 3" controller="Project" action="Details" id="3">

您已经发现了另一种选择,即使用参数。这将使节点始终匹配路由键,而不管其值如何,这通常是执行CRUD操作的管理页面的理想解决方案

<mvcSiteMapNode title="Edit Project" controller="Project" action="Edit" preservedRouteParameters="id">

通常,当您这样做时,您必须稍微调整一下显示,因为在菜单上有一个编辑节点没有多大意义(您通常会从记录列表中选择编辑),并且当您选择它时,您通常希望节点显示您选择的记录。可以使用和来执行此操作

有关通常如何设置一组CRUD操作的完整可下载演示,请参阅标题为的博客文章