public void SetDynamicMeta(MetaInfo objMeta, JsonLDBaseInfo jsonLDInfo, IHttpContextAccessor _httpContextAccessor) { string MetaHtml = CreateMetaTagsHtml(objMeta); string JSONLD = CreateJsonLD(jsonLDInfo); string metatags = MetaHtml + JSONLD; CoreHelper coreHelper = new CoreHelper(); coreHelper.SetHttpContextItem(HttpContextKey.SEOMeta, metatags, _httpContextAccessor); }
private string CreateMetaTagsHtml(MetaInfo objMeta) { SEOProvider provider = new SEOProvider(); IList <SEOMetaType> seoTagList = provider.GetSeoTags().Result as IList <SEOMetaType>; List <SEOAttribute> objSeoAttributeList = new List <SEOAttribute>(); string pageTitle = objMeta.ContentTitle; foreach (SEOMetaType seoMetaType in seoTagList) { string contentValue = seoMetaType.TagName; string content = string.Empty; switch (seoMetaType.TagTypeID) { case 1: //type content = objMeta.ContentType; break; case 2: //title content = objMeta.ContentTitle; break; case 3: //image content = objMeta.ImageURL; break; case 4: //description content = objMeta.ShortDescription; break; } switch (seoMetaType.CrawlerName) { case "facebook": objSeoAttributeList.Add(new SEOAttribute("meta", "property", contentValue, "content", content)); break; case "twitter": objSeoAttributeList.Add(new SEOAttribute("meta", "name", contentValue, "content", content)); break; case "google": objSeoAttributeList.Add(new SEOAttribute("meta", "name", contentValue, "content", content)); break; } } pageTitle = Environment.NewLine + "<title>" + pageTitle + "</title>" + Environment.NewLine; return(pageTitle + SEOHelper.BuildSEOTags(objSeoAttributeList) + AddAdditionalSEO()); }