public IActionResult SitemapXml() { var sitemapUrlList = new SitemapUrlList { SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Index))), 1d), SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Pricing)))), SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Privacy)))), SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(About)))), SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Contact)))), SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Terms)))) }; return(File(Encoding.UTF8.GetBytes(sitemapUrlList.ToXml()), WebPathHelper.GetMimeType(".xml"))); }
public async Task <IActionResult> SitemapXml() { var seller = await HttpContext.GetSellerAsync(); var sitemapList = new SitemapUrlList(); var products = await _productService.GetQuery().Where(x => x.SellerId == seller.Id && x.Published && !string.IsNullOrWhiteSpace(x.Slug)).Select(x => new { x.Slug }).ToListAsync(); var categories = await _categoryService.GetQuery().Where(x => x.SellerId == seller.Id && x.Published && !string.IsNullOrWhiteSpace(x.Slug)).Select(x => new { x.Slug }).ToListAsync(); sitemapList.Add(SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Index))))); sitemapList.AddRange(from product in products select SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Products), "Store", new { slug = product.Slug })))); sitemapList.AddRange(from category in categories select SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Products), "Store", new { slug = category.Slug })))); sitemapList.Add(SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Products))))); sitemapList.Add(SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(About))))); sitemapList.Add(SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Contact))))); sitemapList.Add(SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(Terms))))); sitemapList.Add(SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(PrivacyPolicy))))); sitemapList.Add(SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(ReturnPolicy))))); sitemapList.Add(SitemapUrl.CreateUrl(Url.ContentLink(Url.Action(nameof(ReviewPolicy))))); return(File(Encoding.UTF8.GetBytes(sitemapList.ToXml()), WebPathHelper.GetMimeType(".xml"))); }