0

我有两个类似的视图,其中 MVCSiteMap 面包屑是不可见的。在其他页面上,相同的代码有效。请帮助我弄清楚为什么这两个视图不显示面包屑。Mvc站点地图代码:

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0"
            xsi:schemaLocation="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0 MvcSiteMapSchema.xsd">

  <mvcSiteMapNode title="Главная" controller="Home" action="Index" key="Home">

    <mvcSiteMapNode title="Каталоги" controller="Products" action="Index" key="Products" />
    <mvcSiteMapNode title="Продукция" controller="Products" action="ProductList" key="ProductList" />
    <mvcSiteMapNode title="Новинки" controller="Products" action="ShowNewest" key="ShowNewest" />
    <!--Education-->
    <mvcSiteMapNode title="Обучение" controller="Education" action="Index" key="Education">
      <mvcSiteMapNode title="Видео" controller="Education" action="Video" key="Video" />
      <mvcSiteMapNode title="Мастер-классы видео" controller="Education" action="Video_MasterClass" key="Video_MasterClass" />


      <mvcSiteMapNode title="Отзывы участников" controller="Education" action="FeedbacksParticipants" key="FeedbacksParticipants">

        <!--THIS IS THE FIRST PROBLEM-->     
        <mvcSiteMapNode title="Отзыв участника" controller="Education" action="OneFeedbacksParticipants" key="OneFeedbacksParticipants" />
      </mvcSiteMapNode>  


      <mvcSiteMapNode title="Полное рассписание семинаров" controller="Education" action="AllSeminars" key="AllSeminars" />
      <mvcSiteMapNode title="Семинары по уходу за лицом" controller="Education" action="FaceSeminars" key="FaceSeminars" />
      <mvcSiteMapNode title="Семинары по уходу за телом" controller="Education" action="BodySeminars" key="BodySeminars" />
      <mvcSiteMapNode title="Информация о интересующем семинаре" controller="Education" action="ShowOneSeminar" key="ShowOneSeminar" />
      <mvcSiteMapNode title="Тренинги для руководителей" controller="Education" action="TrainingsForChiefs" key="TrainingsForChiefs" />
      <mvcSiteMapNode title="Тренинги по продажам" controller="Education" action="TrainingsForSalers" key="TrainingsForSalers" />
      <mvcSiteMapNode title="Информация о интересующем тренинге" controller="Education" action="ShowOneTraining" key="ShowOneTraining" />
    </mvcSiteMapNode>
    <!--News-->
    <mvcSiteMapNode title="Новости" controller="News" action="AllNews" key="AllNews" />
    <mvcSiteMapNode title="Новость" controller="News" action="News" key="News" />
    <!--Partners-->
    <mvcSiteMapNode title="Партнеры" controller="Partner" action="AllPartners" key="Partners" />
    <mvcSiteMapNode title="Партнер" controller="Partner" action="Partner" key="OneOfPartners" />
    <!--About company-->
    <mvcSiteMapNode title="О нас" controller="Home" action="AboutUs" key="AboutUs" />
    <mvcSiteMapNode title="О бренде" controller="Home" action="AboutBrand" key="AboutBrand" />
    <mvcSiteMapNode title="Пресса" controller="Social" action="Press" key="Press" />
    <mvcSiteMapNode title="Статья" controller="Press" action="Press" key="Article" />

    <mvcSiteMapNode title="Отзывы" controller="Social" action="Feedback" key="Feedback">

      <!--THIS IS THE SECOND PROBLEM-->     
      <mvcSiteMapNode title="Отзыв подробнее" controller="Social" action="OneFeedback" key="OneFeedback" />
    </mvcSiteMapNode>  


    <!--Contacts-->
    <mvcSiteMapNode title="Контакты" controller="Home" action="Contacts" key="Contacts" />
    <!--Sertificartes-->
    <mvcSiteMapNode title="Сертификаты" controller="Sertificates" action="Index" key="Sertificates" />

  </mvcSiteMapNode>

</mvcSiteMap>

控制器中的代码(教育):

[MvcSiteMapNode(Title = "Отзыв участника", ParentKey = "FeedbacksParticipants")]
        public ActionResult OneFeedbacksParticipants(Int32 id)
        {
            ViewBag.Title = "Отзывы участников";
            ViewBag.Description = "Отзывы об обучении в Астрамед";
            ViewBag.Keywords = "Астрамед, отзывы, обучение, семинары, тренинги, лицо, тело, косметика";
            FeedbackOfParticipantManager manager = new FeedbackOfParticipantManager();
            FeedbackModel model = manager.GetFeedback(id);
            return View(model);
        }

控制器中的代码(社交):

[MvcSiteMapNode(Title = "Отзыв подробнее", ParentKey = "Feedback")]
        public ActionResult OneFeedback(Int32 id)
        {
            ViewBag.Title = "Отзыв подробнее";
            ViewBag.Description = "Отзывы об Астрамед";
            ViewBag.Keywords = "Астрамед, Tegor, отзывы";

            FeedbackManager feedbackManager = new FeedbackManager();
            FeedbackModel model = feedbackManager.GetFeedback(id);
            return View(model);
        }

在视图中,我有下一个代码:

<div class="breadcumbs">@Html.MvcSiteMap().SiteMapPath()</div>

非常感谢

4

1 回答 1

0

问题是您尚未定义如何处理id配置中的参数。默认情况下,您应该为每个可能的id.

在这种情况下,这可能不实用。id另一个选项是通过使用 PreservedRouteParameters 强制每个匹配来配置一对多关系。

[MvcSiteMapNode(Title = "Отзыв участника", ParentKey = "FeedbacksParticipants", PreservedRouteParamters="id")]
public ActionResult OneFeedbacksParticipants(Int32 id)
{
    ViewBag.Title = "Отзывы участников";
    ViewBag.Description = "Отзывы об обучении в Астрамед";
    ViewBag.Keywords = "Астрамед, отзывы, обучение, семинары, тренинги, лицо, тело, косметика";
    FeedbackOfParticipantManager manager = new FeedbackOfParticipantManager();
    FeedbackModel model = manager.GetFeedback(id);
    return View(model);
}

[MvcSiteMapNode(Title = "Отзыв подробнее", ParentKey = "Feedback", PreservedRouteParamters="id")]
public ActionResult OneFeedback(Int32 id)
{
    ViewBag.Title = "Отзыв подробнее";
    ViewBag.Description = "Отзывы об Астрамед";
    ViewBag.Keywords = "Астрамед, Tegor, отзывы";

    FeedbackManager feedbackManager = new FeedbackManager();
    FeedbackModel model = feedbackManager.GetFeedback(id);
    return View(model);
}

参考:

https://github.com/maartenba/MvcSiteMapProvider/wiki/Routing-Basics http://www.shiningtreasures.com/post/2013/09/02/how-to-make-mvcsitemapprovider-remember-a-user-position

注意:您应该只声​​明一次节点,无论是在 XML 中还是作为 .NET 属性。

于 2015-09-08T21:14:37.933 回答