MVCSiteMapProvider 忽略参数
MVCSiteMapProvider ignore parameters
我正在使用 MVCSiteMapProvider.MVC5,我正在尝试设置我的站点地图。
我的路线是:
通知/
notifications/Alarm/
notifications/Warning/
notifications/Information/
警报、警告和信息传递给 "notificationFilter" 操作参数。
这是我的基本站点地图,目前通过面包屑显示路线通知/作为主页>通知。
<mvcSiteMapNode title="Home" controller="Dashboard" action="System">
<mvcSiteMapNode title="Vacuum Management" controller="Dashboard" action="SubSystem" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" />
</mvcSiteMapNode>
我想做的是添加一个包罗万象,这样如果传递了 "notificationFilter" 参数(例如 notifications/Alarm/),它仍将面包屑显示为主页>通知并忽略该参数.
我试过这个:
<mvcSiteMapNode title="Home" controller="Dashboard" action="System">
<mvcSiteMapNode title="Vacuum Management" controller="Dashboard" action="SubSystem" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" notificationFilter="Alarm" />
这对 notifications/Alarm 有效,但没有别的。我还尝试添加多行:
<mvcSiteMapNode title="Home" controller="Dashboard" action="System">
<mvcSiteMapNode title="Vacuum Management" controller="Dashboard" action="SubSystem" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" notificationFilter="Alarm" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" notificationFilter="Warning" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" notificationFilter="Information" />
但是因为标题是关键所以面包屑会显示不同的文本。
感谢所有帮助。
提前致谢!
路由配置:
routes.MapRoute(
name: "NotificationsSystem",
url: "notifications",
defaults: new { controller = "Notifications", action = "SystemNotifications", notificationFilter = "" }
);
routes.MapRoute(
name: "NotificationsSystemFiltered",
url: "notifications/{notificationFilter}",
defaults: new { controller = "Notifications", action = "SystemNotifications", notificationFilter = "" }
);
根据 the documentation,可以使用 preservedRouteParameters
.[=14= 来让单个节点匹配特定参数的 any 值]
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" preservedRouteParameters="notificationFilter" />
当您的节点没有子节点时,这很有效,但是如果您将此属性放在有子节点的节点上,则需要 take into consideration what will happen when the user navigates back up the hierarchy。
我正在使用 MVCSiteMapProvider.MVC5,我正在尝试设置我的站点地图。
我的路线是:
通知/
notifications/Alarm/
notifications/Warning/
notifications/Information/
警报、警告和信息传递给 "notificationFilter" 操作参数。
这是我的基本站点地图,目前通过面包屑显示路线通知/作为主页>通知。
<mvcSiteMapNode title="Home" controller="Dashboard" action="System">
<mvcSiteMapNode title="Vacuum Management" controller="Dashboard" action="SubSystem" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" />
</mvcSiteMapNode>
我想做的是添加一个包罗万象,这样如果传递了 "notificationFilter" 参数(例如 notifications/Alarm/),它仍将面包屑显示为主页>通知并忽略该参数.
我试过这个:
<mvcSiteMapNode title="Home" controller="Dashboard" action="System">
<mvcSiteMapNode title="Vacuum Management" controller="Dashboard" action="SubSystem" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" notificationFilter="Alarm" />
这对 notifications/Alarm 有效,但没有别的。我还尝试添加多行:
<mvcSiteMapNode title="Home" controller="Dashboard" action="System">
<mvcSiteMapNode title="Vacuum Management" controller="Dashboard" action="SubSystem" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" notificationFilter="Alarm" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" notificationFilter="Warning" />
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" notificationFilter="Information" />
但是因为标题是关键所以面包屑会显示不同的文本。
感谢所有帮助。
提前致谢!
路由配置:
routes.MapRoute(
name: "NotificationsSystem",
url: "notifications",
defaults: new { controller = "Notifications", action = "SystemNotifications", notificationFilter = "" }
);
routes.MapRoute(
name: "NotificationsSystemFiltered",
url: "notifications/{notificationFilter}",
defaults: new { controller = "Notifications", action = "SystemNotifications", notificationFilter = "" }
);
根据 the documentation,可以使用 preservedRouteParameters
.[=14= 来让单个节点匹配特定参数的 any 值]
<mvcSiteMapNode title="Notifications" controller="Notifications" action="SystemNotifications" preservedRouteParameters="notificationFilter" />
当您的节点没有子节点时,这很有效,但是如果您将此属性放在有子节点的节点上,则需要 take into consideration what will happen when the user navigates back up the hierarchy。