private void SubmitEngine(string engine, string sitemapUrl) { //Check if it is not localhost because search engines returns an error if (!sitemapUrl.Contains("http://localhost")) { string request = string.Concat(engine, SitemapItem.HtmlEncode(sitemapUrl)); System.Net.HttpWebRequest httpRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(request); try { System.Net.WebResponse webResponse = httpRequest.GetResponse(); System.Net.HttpWebResponse httpResponse = (System.Net.HttpWebResponse)webResponse; if (httpResponse.StatusCode != System.Net.HttpStatusCode.OK) { Log.Error(string.Format("Cannot submit sitemap to \"{0}\"", engine), this); } } catch { Log.Warn(string.Format("The serachengine \"{0}\" returns an 404 error", request), this); } } }
public SitemapItem(Item item, SiteContext site, Item parentItem) { Priority = item[Constants.SeoSettings.Priority]; ChangeFrequency = item[Constants.SeoSettings.ChangeFrequency].ToLower(); LastModified = HtmlEncode(item.Statistics.Updated.ToLocalTime().ToString("yyyy-MM-ddTHH:mm:sszzz")); Id = item.ID.Guid; Title = item[Constants.SeoSettings.Title]; var itemUrl = HtmlEncode(GetItemUrl(item, site)); if (parentItem == null) { Location = itemUrl; } else { Location = GetSharedItemUrl(item, site, parentItem); } Language[] languages = item.Languages; HrefLangs = new List <SitemapItemHrefLang>(); Language[] languageArray = languages; for (int i = 0; i < (int)languageArray.Length; i++) { Language language = languageArray[i]; string sharedItemUrl = SitemapItem.HtmlEncode(SitemapItem.GetItemUrl(item, site, language)); if (parentItem != null) { sharedItemUrl = SitemapItem.GetSharedItemUrl(item, site, parentItem); } this.HrefLangs.Add(new SitemapItemHrefLang() { Href = sharedItemUrl, HrefLang = language.CultureInfo.TwoLetterISOLanguageName }); } }