MVC 3 Sitemap提供程序-指向同一节点的多个路径 [英] mvc 3 sitemap provider- multiple paths pointing to same node

查看:89
本文介绍了MVC 3 Sitemap提供程序-指向同一节点的多个路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用marteenba的站点地图提供程序,因为我无法解决以下问题:我拥有的另一个站点地图.比我以前的更好.我的问题是:如何从转到单个主页的页面创建不同的痕迹?考虑以下想法:

i've recently started to use marteenba's sitemap provider, because i couldn't solve a route problem with the other sitemap i had. It's way better than my previous one. My question is: how can i create different breadcrumb trails from pages that go to a single main page? Consider the idea below:

站点地图结构

<mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
       <mvcSiteMapNode title="Clients Search" controller="ClientBussiness" action="ClientSearch" description="Clients Search">
            <mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
        </mvcSiteMapNode>

        <mvcSiteMapNode title="Advanced Search" controller="ClientBussiness" action="AdvancedSearch" description="Clients Advanced Search">
            <mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
        </mvcSiteMapNode>

        <mvcSiteMapNode title="Another Search" controller="ClientBussiness" action="AnotherSearch" description="Clients Another Search">
            <mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
        </mvcSiteMapNode>
</mvcSiteMapNode>

在上面的示例中,我的面包屑跟踪始终显示客户端搜索"节点,而不是其他节点.我不知道是否应该为每种搜索创建不同的路线(我在上一个站点地图中做了此操作,但是很遗憾iis6不喜欢它).

On the example above, my breadcrumb trail always shows the node Clients Search instead of any other. I don't know if should create different routes for each kind of search (i did this on my last sitemap, but unfortunately iis6 didn't like it).

感谢您的帮助.

编辑

在论坛上搜索时,我发现了一个类似的问题.因此,请考虑以下结构:

searching on forums i found a similar question. So, consider the structure below:

Home >> Search >> Contracts
Home >> Another Search >> Contracts
Home >> Advanced Search >> Contracts
Home >> Web Service Search >> Extra fields >> Contracts

推荐答案

看来,我要做的只是在控制器上添加一些动态节点属性.您可以此处.使用上面的示例,这是完成的过程:

Well it seems that all i needed to do was to add some dynamic nodes attributes on my controllers. You can read how to do it here. Using the example above, here's how it's done:

 [MvcSiteMapNodeAttribute(Title = "Search", Key = "search", ParentKey = "ContractSearch", Route = "SearchRoute")]
        [MvcSiteMapNodeAttribute(Title = "AdvancedSearch", Key = "ContractAdvSearch", ParentKey = "AdvSearch", Route = "AdvSearchRoute")]
        [MvcSiteMapNodeAttribute(Title = "AnotherSearch", Key = "ContractAnotherSearch", ParentKey = "AnotherSearch", Route = "AnotherSearchRoute")]
        public ActionResult ContractIndex()
{
   //Things to do...         
}

在上面的示例中,每种搜索都将在面包屑路径中正确定义. 请记住,您必须为每种要使用的搜索"定义不同的路线.因此,如果要让3个节点指向相同的url,则每个节点必须具有自己的路由和密钥,在MvcSiteMapNodeAttribute上定义.

On the example above, each kind of search will be properly defined on the breadcrumb trail. Keep in mind that you have to define different routes for each kind of "search" you want to use. So, if you want to have 3 nodes pointing to the same url, each node must have it's own route and it's key, defined on MvcSiteMapNodeAttribute.

这篇关于MVC 3 Sitemap提供程序-指向同一节点的多个路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆