2017-07-13 3 views

Répondre

0

Ok,

Je trouve la réponse debuggin, ce travail pour moi.

public class SEOProperties { 

    public string PropBrowserTitle   { get; set; } 
    public string PropBrowserDescription { get; set; } 
    public string PropBrowserKeyWords  { get; set; } 
    public string PropBrowserSiteNoIndex { get; set; } 

} 

    private SEOProperties GetSEOProperties(){ 

    SEOProperties SEO = new SEOProperties(); 
    if (SPContext.Current != null) 
       { 
        Guid siteGuid = SPContext.Current.Site.ID; 
        Guid webGuid = SPContext.Current.Web.ID; 

        using (SPSite site = new SPSite(siteGuid)) 
        { 
         using (SPWeb web = site.OpenWeb()) 
         { 
          TaxonomySession session  = new TaxonomySession(site); 
          NavigationTerm navTermino = TaxonomyNavigationContext.Current.NavigationTerm; 
          Term   termino  = navTermino.GetTaxonomyTerm(session); 

          var SEOPropBrowserTitle = termino.LocalCustomProperties.Where(o => o.Key == "_Sys_Seo_PropBrowserTitle").SingleOrDefault(); 
          var SEOPropDescription = termino.LocalCustomProperties.Where(o => o.Key == "_Sys_Seo_PropDescription").SingleOrDefault(); 
          var SEOPropKeyWords  = termino.LocalCustomProperties.Where(o => o.Key == "_Sys_Seo_PropKeywords").SingleOrDefault(); 
          var SEOPropSiteNoIndex = termino.LocalCustomProperties.Where(o => o.Key == "_Sys_Seo_PropSitemapNoIndex").SingleOrDefault(); 

          SEO.PropBrowserDescription = SEOPropDescription.Value; 
          SEO.PropBrowserKeyWords  = SEOPropKeyWords.Value; 
          SEO.PropBrowserSiteNoIndex = SEOPropSiteNoIndex.Value; 
          SEO.PropBrowserTitle  = SEOPropBrowserTitle.Value; 
         } 
        } 
       } 
       return SEO; 
}