/// <summary> /// Called by the MVC framework after the action method executes. /// </summary> /// <param name="filterContext">The filter context.</param> public override void OnActionExecuted(ActionExecutedContext filterContext) { ViewResult result = filterContext.Result as ViewResult; if (result != null) { var target = (ResolveTarget(result.ViewData.Model, PropertyName) ?? ResolveTarget(result.ViewData, PropertyName)) ?? result.ViewData[PropertyName]; if (target != null) { ISiteMap siteMap = SiteMaps.GetSiteMap(this.SiteMapCacheKey); if (siteMap != null && siteMap.CurrentNode != null) { if (Target == AttributeTarget.ParentNode && siteMap.CurrentNode.ParentNode != null) { siteMap.CurrentNode.ParentNode.Title = target.ToString(); } else { siteMap.CurrentNode.Title = target.ToString(); } } } } }
/// <summary> /// Creates a new MvcSiteMapProvider HtmlHelper. /// </summary> /// <param name="helper">The helper.</param> /// <param name="siteMapCacheKey">The SiteMap Cache Key.</param> /// <returns> /// A <see cref="MvcSiteMapHtmlHelper"/> instance /// </returns> public static MvcSiteMapHtmlHelper MvcSiteMap(this HtmlHelper helper, string siteMapCacheKey) { ISiteMap siteMap = SiteMaps.GetSiteMap(siteMapCacheKey); if (siteMap == null) { throw new UnknownSiteMapException(); } return(MvcSiteMap(helper, siteMap)); }