我有一个带有不同参数的链接“票证/索引”。我使用路由创建了带有此链接及其参数的菜单。菜单显示正确,但面包屑未显示!
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 });
}
答案 0 :(得分:0)
哇!我找到了!我在节点元素上添加了url
,并使用了下面的路由。现在,我可以看到每个菜单的面包屑。提示是将url
添加到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 });
}