我正在使用 MvcSiteMapProvider 4.6.3、MVC 4。
我想使用 Html.MvcSiteMap().Menu() 来生成菜单。
问题是我在 URL 中有多个参数,这些参数会根据用户和文档 ID 进行更改。
我的站点地图如下所示:
<mvcSiteMapNode title="Home" controller="Home" action="Index">
<mvcSiteMapNode title="Site Map Test" controller="SitemapTest" action="Index" area="" key="sitemaptestnode">
<mvcSiteMapNode title="Sub1" controller="SitemapTest" action="Sub1" area="" />
<mvcSiteMapNode title="Sub2" controller="SitemapTest" action="Sub2" area="" />
</mvcSiteMapNode>
</mvcSiteMapNode>
这些动作需要不同的参数。
public ActionResult Index(string id, string clientId)
{
return View();
}
public ActionResult Sub1(string id, string productId)
{
return View();
}
public ActionResult Sub2(string id, string staffId)
{
return View();
}
我尝试使用 Html 助手来生成菜单。
@Html.MvcSiteMap().Menu(node, false, false)
因此,如果我在索引页面上。菜单应该是
站点地图Test/Index/product1?clientId=clientId2
站点地图Test/Index/client1?productId=product2
SitemapTest/Index/client1?staffId=staffId1
这些 id 是从数据库中获取的。
有没有办法将参数传递给 Html 帮助以指定每个链接使用哪个 Id?