1
votes

I'm trying to get MvcSiteMapProvider to work with a simple site which performs some CRUD operations. I'm almost accomplished that, but I'm getting strange behaviour in many scenarios.

First, I created the Controller and Views using stardard hierachy:
Controllers
--> EquipoController
Views
--> Equipo --> Index / Details / Create / Edit / Delete...

Next, defined my mvc.sitemap

<mvcSiteMapNode title="Inicio" controller="Home">
  <mvcSiteMapNode title="Equipo" controller="Equipo">
    <mvcSiteMapNode title="Crear Equipo" action="Create"></mvcSiteMapNode>
    <mvcSiteMapNode title="Detalle Equipo" action="Details" dynamicNodeProvider="MvcApplication2.TestDynamicNodeProvider, MvcApplication2">
      <mvcSiteMapNode title="Editar Equipo" action="Edit"></mvcSiteMapNode>
      <mvcSiteMapNode title="Eliminar Equipo" action="Delete"></mvcSiteMapNode>
    </mvcSiteMapNode>
  </mvcSiteMapNode>

Note that Edit and Delete operations are nested in Details node.

Next, I implemented the TestDynamicNodeProvider class as follows: public class TestDynamicNodeProvider : DynamicNodeProviderBase { Entities db = new Entities();

    public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
    {
        // Build value 
        var returnValue = new List<DynamicNode>();

        // Create a node for each album 
        foreach (var equipo in db.GEN_EQUIPO)
        {
            DynamicNode node = new DynamicNode();
            node.Title = equipo.DESCRIPCION;
            node.RouteValues.Add("id", equipo.ID);                
            yield return node;                
        }            
    }
}

Supose that I have two items in GEN_EQUIPO (EQUIPO_A and EQUIPO_B). These are the breadcrumbs I get in every view:
Index: Inicio > Equipo (easy...)
Details view (2nd item): Inicio > Equipo > EQUIPO_B (ok)
Edit view (2nd item): Inicio > Equipo > EQUIPO_A > Editar Equipo (wrong!)
Delete view (2nd item): Inicio > Equipo > EQUIPO_A > Eliminar Equipo (wrong!)

I can't figure why in edit and delete view it builds the breadcrumb using always the first item on the list. Also the link is wrong (Equipo/Details/1 when it should be Equipo/Details/2)

I attach a capture for more example.

I have no clue of what I'm doing wrong! Any idea?

Look at direction bar... and then to the link generated. Also, see that TALADRO is not TRONZADORA!

1
One month after and not a single answer. Maybe my question is bad written? Please let me know... - Farlop

1 Answers

0
votes

Have you tried adding "preservedRouteParameters" to your details, edit and delete nodes? I would assume you're using a field such as "id" so it would look like:

preservedRouteParameters="id"