MvcSitemapProvider - adding value to ignore in url resolver

I have a link in my url that includes dynamic identifiers, i.e.

/ controller / action / identifier

There is currently no requirement that each of my pages has its own summary, it would be better to return to the action index pattern or just set the parent resolving URL.

Is there a simple solution or any tips to solve this problem?

Thank you in advance

+2
source share
1 answer

There are two ways to use "id" or any other route value using MvcSiteMapProvider.

1. node "id" ( DynamicNodeProviderBase). 1 1 "id" node. , < 10 000 , , .

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

2. node, "id" , RouteParameters = "id" node. 1--1 "id" ( ) node. ; Menu, SiteMap /sitemap.xml , SiteMapTitle, . , .

<mvcSiteMapNode title="Product 1" controller="Product" action="Details" preservedRouteParameters="id"/>

, node, . , , "userId" , , ( node [ "id" ] X [ "userId" ], node ) SiteMap, "userId" , .

<mvcSiteMapNode title="Product 1" controller="Product" action="Details" id="1" preservedRouteParameters="userId"/>
<mvcSiteMapNode title="Product 2" controller="Product" action="Details" id="2" preservedRouteParameters="userId"/>
<mvcSiteMapNode title="Product 3" controller="Product" action="Details" id="3" preservedRouteParameters="userId"/>

, XML - .

, : MvcSiteMapProvider .

+2

Source: https://habr.com/ru/post/1526796/


All Articles