asp net MVC 5 SiteMap - build breadcrumb to another controller
<p>I developing breadcrumbs for my asp net mvc e-commerce. I have a controller for my categories. It looks like this:</p>

<pre><code> public class CategoryController : AppController
    {

    public ActionResult Index(string cat1, string cat2, string cat3, int? page)
        {

... some code

       // build breadcrumbs from parent cats
        int indexer = 0;
        foreach(var item in parCategories) //parCategories - list of parent categories
        {
            string currCatIndex = new StringBuilder().AppendFormat("category{0}", indexer + 1).ToString(); //+2 cause arr index begins from 0
            var currNode = SiteMaps.Current.FindSiteMapNodeFromKey(currCatIndex);           
            currNode.Title= parCategories.ElementAt(indexer).Name;
            indexer++;
        }

        string finalCatIndex = new StringBuilder().AppendFormat("category{0}", CategoryDepth + 1).ToString();
        var node = SiteMaps.Current.FindSiteMapNodeFromKey(finalCatIndex);
        node.Title = CurrCategory.Category.Name;

       //show View
        }
}
</code></pre>

<p>A'm showing list of products. If user opens product, request performing with another controller:</p>

<pre><code>  public class ProductController : AppController
    {
        // GET: Product
        public ActionResult Index(string slug)
        {   
           // find product by slug and show it
        }
</code></pre>

<p>Here is my rout config:  </p>

<pre><code> routes.MapRoute(
                name: "Category",
                url: "Category/{cat1}/{cat2}/{cat3}",
                defaults: new { controller = "Category", action = "Index", cat1 = UrlParameter.Optional, cat2= UrlParameter.Optional, cat3 = UrlParameter.Optional }    
            );

            routes.MapRoute(
               name: "Product",
               url: "Product/{slug}",
               defaults: new { controller = "Product", action = "Index", slug = UrlParameter.Optional}
           );
</code></pre>

<p>And sitemap for categories (works perfect):</p>

<pre><code> &lt;mvcSiteMapNode title="Категории" controller="Category" action="Index" route="Category" preservedRouteParameters="cat1" key="category1"&gt;
      &lt;mvcSiteMapNode title="Категории2" controller="Category" action="Index" route="Category" preservedRouteParameters="cat1;cat2" key="category2"&gt;
        &lt;mvcSiteMapNode title="Категории3" controller="Category" action="Index" route="Category" preservedRouteParameters="cat1;cat2;cat3" key="category3" /&gt;
      &lt;/mvcSiteMapNode&gt;
    &lt;/mvcSiteMapNode&gt;
</code></pre>

<p>But I dont know how to build bredcrumbs for product like this:</p>

<pre><code>Home&gt;cat1&gt;Product_name
Home&gt;cat1&gt;cat2&gt;Product_name
Home&gt;cat1&gt;cat2&gt;cat3&gt;Product_name
</code></pre>

<p><strong>What I tried:</strong></p>

<p>This sitemap:</p>

<pre><code> &lt;mvcSiteMapNode title="Категории" controller="Category" action="Index" route="Category" preservedRouteParameters="cat1" key="category1"&gt;
      &lt;mvcSiteMapNode title="Prod" controller="Product" action="Index" route="Product" preservedRouteParameters="slug" key="prod1" /&gt;
      &lt;mvcSiteMapNode title="Категории2" controller="Category" action="Index" route="Category" preservedRouteParameters="cat1;cat2" key="category2"&gt;
        &lt;mvcSiteMapNode title="Prod" controller="Product" action="Index" route="Product" preservedRouteParameters="slug" key="prod2" /&gt;
        &lt;mvcSiteMapNode title="Категории3" controller="Category" action="Index" route="Category" preservedRouteParameters="cat1;cat2;cat3" key="category3" &gt;
          &lt;mvcSiteMapNode title="Prod" controller="Product" action="Index" route="Product" preservedRouteParameters="slug" key="prod3" /&gt;
        &lt;/mvcSiteMapNode&gt;
        &lt;/mvcSiteMapNode&gt;
    &lt;/mvcSiteMapNode&gt; 
</code></pre>

<p>And also I tried custom DynamicNodeProvider</p>

<pre><code>&lt;mvcSiteMapNode title="Товар" controller="Product" action="Index" route="Product" preservedRouteParameters="slug" key="prodDyn" dynamicNodeProvider="FlatCable_site.Libs.Mvc.ProductNodeProvider, FlatCable_site" /&gt;
</code></pre>

<p>And provider:  </p>

<pre><code>  public class ProductNodeProvider : DynamicNodeProviderBase
        {
            public override IEnumerable&lt;DynamicNode&gt; GetDynamicNodeCollection(ISiteMapNode node)
            {

    // tried to get action parameter (slug) and get product by slug, then build category hierarchy but it doesn't passing
    // also this code calls on each page, not only on *site.com/Product/test_prod*

}
</code></pre>