mvc 3站点地图提供程序-指向同一节点的多个路径

发布于 2024-12-03 08:56:42 字数 1567 浏览 2 评论 0原文

我最近开始使用 marteenba 的 站点地图提供程序,因为我无法解决其他站点地图的路线问题我有。这比我之前的好多了。我的问题是:如何从转到单个主页的页面创建不同的面包屑路径?考虑下面的想法:

站点地图结构

<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 不喜欢它)。

我很感激你的帮助。

编辑

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

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

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:

Sitemap Structure

<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>

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).

I appreciate your help.

EDIT

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落花浅忆 2024-12-10 08:56:42

看来我需要做的就是在我的控制器上添加一些动态节点属性。您可以在此处阅读操作方法。使用上面的示例,其完成方式如下:

 [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 上定义)。

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...         
}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文