2012-06-08 50 views
1
我目前使用MVCSiteMapProvider產生面包屑爲我的網站

。我通過在SiteMapTitle屬性中傳遞viewData值來創建站點地圖標題。當我第一次訪問鏈接時會根據需要創建breadCrumb,但是當我嘗試重新訪問來自我的網站的任何其他鏈接時,它將顯示Viewdata對標題的首次訪問值。代碼如下所示MvcSiteMapProvider沒有更新地圖標題

[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> 

任何幫助,將不勝感激

回答

0

正是由於緩存可能由供應商實施。您可以嘗試將cacheduration(在web.config中)設置爲0,以禁用緩存,但這會對性能產生很大影響。

0

你應該升級到MvcSiteMapProvider V4。這是一個現在已經修復的緩存錯誤。此外,您不應使用SiteMapPreserveRouteDataAttribute,因爲它現在已被棄用。爲了保留路由值,您應該在ISiteMapNode對象上使用preservedRouteParameters。

請參閱如何使用preservedRouteParameters實例名爲How to Make MvcSiteMapProvider Remember a User's Position的博客文章。