我目前正在使用 MVCSiteMapProvider 为我的网站生成面包屑。我通过在 SiteMapTitle 属性中传递 viewData 值来创建站点地图标题。当我第一次访问链接时,它会根据需要创建面包屑,但是当我尝试重新访问我网站上的任何其他链接时,它会显示标题的 Viewdata 的第一次访问值。代码看起来像这样
[SiteMapPreserveRouteData]
[SiteMapTitle("atlas")]
public ActionResult Index(string id ,string Atlas)
{
if (!string.IsNullOrEmpty(Atlas))
{
ViewData["atlas"] = Atlas;
}
Taxonomy taxonomy = db.GetTaxonomy(new Guid(ConfigurationManager.AppSettings["TherapyId"]));
var atlasList = taxonomy.GetTerms(id, 2);
return View(atlasList);
}
站点地图看起来像这样
<mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal" >
<mvcSiteMapNode title="Therapy" controller="Therapy" action="Index" >
<mvcSiteMapNode title="" controller="Atlas" action="Index" >
<mvcSiteMapNode title="" controller="Specialties" action="Index">
<mvcSiteMapNode title="" controller="Specialties" action="ViewImage" />
</mvcSiteMapNode>
</mvcSiteMapNode>
</mvcSiteMapNode>
任何帮助将不胜感激