2 nodes in mvc.sitemap refers to 1 action with different parameters and they are not shown in breadcrumbs
Asked Answered
S

1

0

I have a link "Ticket/Index" with different parameters. I created a menu with this link and its parameters using routing. The menu is shown correctly but the breadcrumbs don't show them!

Mvc.sitemap:

<mvcSiteMapNode id="Admin" title="Admin Menu"  clickable="false" imageUrl="fa fa-th" >
    <mvcSiteMapNode title="Users"  controller="User" action="Index" />
    <mvcSiteMapNode title="Projetcs"  controller="Project" action="Index" />
    <mvcSiteMapNode title="Admin Tickets" controller="Admin" action="Index" /> ===> Ticket/index?role=0
</mvcSiteMapNode>

<mvcSiteMapNode id="Supporter" title="Support Menu"    clickable="false" imageUrl="fa fa-th" >
    <mvcSiteMapNode title="New Tickets" controller="Support" action="ListWaiting" /> ===> Ticket/Index?role=3&mode=receive&status=0
    <mvcSiteMapNode title="Add New Ticket"  controller="Ticket" action="Insert"/> 
</mvcSiteMapNode>

RouteConfig.cs :

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "AdminTicketIndex",
            url: "Admin/Index",
            defaults: new { controller = "Ticket", action = "Index", role = 0 });

        routes.MapRoute(
            name: "SupportTicketIndex",
            url: "Support/ListWaiting",
            defaults: new { controller = "Ticket", action = "Index", role = 3, mode = "receive", status = 0 });

        routes.MapRoute(
          name: "Default",
          url: "{controller}/{action}/{id}",
          defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional });
    }
Shenitashenk answered 14/5, 2019 at 10:29 Comment(0)
S
0

Wow! I found it! I added url to node elements and I used the below rout for it. Now I can see breadcrumbs for each menu. The clue was adding url to SiteMapNode.

mvc.sitemap:

  <mvcSiteMapNode id="Admin" title="Admin Menu" clickable="false" imageUrl="fa fa-th" >
      <mvcSiteMapNode title="Users" controller="User" action="Index" />
      <mvcSiteMapNode title="Projetcs" controller="Project" action="Index" />
      <mvcSiteMapNode title="Admin Tickets" controller="Ticket" action="Index/0" url="/Ticket/Index/0" />
    </mvcSiteMapNode>

   <mvcSiteMapNode id="Supporter" title="Support Menu" clickable="false" imageUrl="fa fa-th" >
      <mvcSiteMapNode id="Waiting" title="New Tickets" controller="Ticket" action="Index/3/receive/0" url="/Ticket/Index/3/receive/0" />
        <mvcSiteMapNode title="Add New Ticket" controller="Ticket" action="Insert/3" url="/Ticket/Insert/3"/>
   </mvcSiteMapNode>

RouteConfig.cs :

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
          name: "TicketIndex",
          url: "{controller}/{action}/{role}/{mode}/{status}",
          defaults: new { controller = "Ticket", action = "Index", role = UrlParameter.Optional, mode = UrlParameter.Optional, status = UrlParameter.Optional });

        routes.MapRoute(
          name: "Default",
          url: "{controller}/{action}/{id}",
          defaults: new {controller = "Account", action = "Login", id = UrlParameter.Optional });

    }
Shenitashenk answered 15/5, 2019 at 8:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.