Problem with extra parameters in ActionMethod

Sep 27, 2010 at 10:08 AM

Hi.

 

I've configured my siteMap and when I enter address /Products/Overview/1 everything works fine.

Now I need to pass to the Overview action method extra integer (optional) parameter named 'category'. The address with category parameter will be: /Products/Overview/1/10. And the problem is that the breadcrumb is not displayed (the breadcrumb have to be the same as in /Products/Overview/1 address).

 

The category parameter doesn't generate any dynamic nodes. It is only an extra information.

 

So the question is, how to write one siteMapNode that covers the scenario with: a) only id parameter b) with id and category parameter.

 

Chris.

Oct 1, 2010 at 12:21 PM

Can you post your sitemap and your action method?

Oct 2, 2010 at 9:16 AM

Hi,

 

Here is my sitemap:

<?xml version="1.0" encoding="utf-8" ?>

<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
  <mvcSiteMapNode title="Start" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
    <mvcSiteMapNode title="Products" controller="Products" action="Index" changeFrequency="Always" updatePriority="Normal">
      <mvcSiteMapNode title="_dynamic_" action="Overview" dynamicNodeProvider="TempPrj.Web.ProductsDynamicNodeProvider, TempPrj.Web">
        <mvcSiteMapNode title="Prices" action="Prices" dynamicNodeProvider="TempPrj.Web.ProductPricesDynamicNodeProvider, TempPrj.Web"/>
      </mvcSiteMapNode>
    </mvcSiteMapNode>
  </mvcSiteMapNode>
</mvcSiteMap>

Action method:

public ActionResult Prices(string id, int? edition)
{
    var product = GetProduct(id);

    return View(product);
}

Chris

Oct 4, 2010 at 11:21 AM

Because you are using dynamic sitemap generation here, MvcSiteMap requires you to add all nodes yourself. In theory, ProductPricesDynamicNodeProvider could return both versions for inclusion in the sitemap.