I've been messing with MVC SiteMapProvider for a little while and love it. I'm building an ecommerce site and it has worked really well so far during my development.
The one issue I can't seem to wrap my head around is how to get dynamicNode to work on first level.
Something like this:
www.mysite.com/{type}/{category}/{filter}
There are only 3 types so for now I just have 3 controllers named after the type and they all use the same logic and viewModels which is not an ideal set up for maintainability down the line. My routeConfig includes 3 routes like this.
routes.MapRoute(
name: "Hardscape",
url: "hardscape-products/{category}/{filter}",
defaults: new { controller = "Products", action = "Index", category = UrlParameter.Optional, filter = UrlParameter.Optional},
namespaces: new[] { "MyApp.Web.Controllers" }
);
routes.MapRoute(
name: "Masonry",
url: "masonry-products/{category}/{filter}",
defaults: new { controller = "Products", action = "Index", category = UrlParameter.Optional, filter = UrlParameter.Optional},
namespaces: new[] { "MyApp.Web.Controllers" }
);
routes.MapRoute(
name: "Landscape",
url: "landscape-products/{category}/{filter}",
defaults: new { controller = "Products", action = "Index", category = UrlParameter.Optional, filter = UrlParameter.Optional},
namespaces: new[] { "MyApp.Web.Controllers" }
);
I've tried something like this but it returns 404.
routes.MapRoute(
name: "Products",
url: "{productType}/{category}/{filter}",
defaults: new { controller = "Products", action = "Index", productType = UrlParameter.Optional, category = UrlParameter.Optional, filter = UrlParameter.Optional},
namespaces: new[] { "MyApp.Web.Controllers" }
);
I've been able to generate my nodes in the sitemap and menu using dynamicNode for my category and filter parameter. Just having trouble with first level when I'm not naming the first level statically
masonry-products/ vs. {productType}/
Please let me know if you have a solution. Hopefully NightOwl can chime in.