/// <summary> /// Action for handling the sitemap request. /// </summary> public ContentResult Index() { var dailyUrls = new List <string>(); dailyUrls.Add(GetUrl(new { controller = "Home", action = "Index" })); foreach (var item in CategoryType.All.ToSelectList(CategoryType.All)) { dailyUrls.Add(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", GetUrl(new { controller = "Category", action = "Index" }), item.Value)); } var weeklyUrl = new List <string>(); weeklyUrl.Add(GetUrl(new { controller = "Home", action = "FAQs" })); weeklyUrl.Add(GetUrl(new { controller = "Home", action = "InstallWWT" })); weeklyUrl.Add(GetUrl(new { controller = "Home", action = "ExcelAddInWelcome" })); var communityList = _communityService.GetLatestCommunityIDs(Constants.SitemapCount); foreach (var item in communityList) { weeklyUrl.Add(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", GetUrl(new { controller = "Community", action = "Index" }), item)); } var contentList = _contentService.GetLatestContentIDs(Constants.SitemapCount); foreach (var item in contentList) { weeklyUrl.Add(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", GetUrl(new { controller = "Content", action = "Index" }), item)); } var profileList = ProfileService.GetLatestProfileIDs(Constants.SitemapCount); foreach (var item in profileList) { weeklyUrl.Add(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", GetUrl(new { controller = "Profile", action = "Index" }), item)); } XNamespace xmlns = "http://www.sitemaps.org/schemas/sitemap/0.9"; ////Build the SiteMap var sitemap = new XDocument( new XDeclaration("1.0", "UTF-8", "yes"), new XElement(xmlns + "urlset", from i in dailyUrls select new XElement(xmlns + "url", new XElement(xmlns + "loc", i), new XElement(xmlns + "lastmod", string.Format(CultureInfo.InvariantCulture, "{0:yyyy-MM-dd}", DateTime.Now)), new XElement(xmlns + "changefreq", "daily"), new XElement(xmlns + "priority", "1")))); sitemap.Root.Add(from i in weeklyUrl select new XElement(xmlns + "url", new XElement(xmlns + "loc", i), new XElement(xmlns + "lastmod", string.Format(CultureInfo.InvariantCulture, "{0:yyyy-MM-dd}", DateTime.Now)), new XElement(xmlns + "changefreq", "weekly"), new XElement(xmlns + "priority", "0.5"))); return(Content(sitemap.Declaration.ToString() + sitemap.ToString(), "text/xml")); }