public IActionResult Index() { var allPages = this.sitePageRepository.GetLivePage(1, MaxPageSizeForSiteMap, out int total); var siteMapHelper = new SiteMapHelper(); foreach (var page in allPages) { if (!page.IsLive || page.ExcludePageFromSiteMapXml) { continue; } string url; if (page.IsSectionHomePage) { url = new Uri(UrlBuilder.GetCurrentDomain(this.HttpContext)).ToString(); } else { url = new Uri(UrlBuilder.GetCurrentDomain(this.HttpContext) + UrlBuilder.BlogUrlPath(page.SitePageSection.Key, page.Key)).ToString().TrimEnd('/'); } var lastUpdated = page.UpdateDate == null ? page.CreateDate : (DateTime)page.UpdateDate; siteMapHelper.AddUrl(url, lastUpdated, ChangeFrequency.Weekly, .5); } var xml = siteMapHelper.GenerateXml(); return(this.Content(xml, "text/xml")); }
public IActionResult Index() { int total; var allBlogs = _blogEntryRepository.GetLivePage(1, int.MaxValue, out total); var siteMapHelper = new SiteMapHelper(); foreach (var blog in allBlogs) { if (!blog.IsLive) { continue; } var url = new Uri(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.ToUriComponent() + UrlBuilder.BlogUrlPath(blog.Key, blog.BlogPublishDateTimeUtc)); var lastUpdated = blog.UpdateDate == null ? blog.CreateDate : (DateTime)blog.UpdateDate; siteMapHelper.AddUrl(url.ToString(), lastUpdated, ChangeFrequency.weekly, .5); } var xml = siteMapHelper.GenerateXml(); return(Content(xml, "text/xml")); }