Quantcast
Channel: sitemaps.xml in asp.net mvc - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by profanis for sitemaps.xml in asp.net mvc

$
0
0

It is important for crawlers to be able to crawl your site quicker and with more accurate.

You can create a controller, say siteMapController and in Index add the following

 public ActionResult Index() {        var xmlString ="<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">";        xmlString +="<url>"+"<loc>Your site</loc>"+"<changefreq>weekly</changefreq>"+"<priority>0.6</priority>"+"</url>"+"<url>"+"<loc>Static Link of you site</loc>"+ //you can add as many you want"<changefreq>weekly</changefreq>"+"<priority>0.6</priority>"+"</url>"+"<url>";           //Dynamic links            xmlString += "<url>"+"<loc>Link of new item"</loc>"+"<lastmod>"+ DateTime.Now.ToString("yyyy-MM-dd") +"</lastmod>"+"<changefreq>daily</changefreq>"+"<priority>0.8</priority>"+"</url>";        }        xmlString += "</urlset>";        ViewData["siteMap"] = xmlString;        return View();    }

save the xml on your server and post the sitemap via this link

https://www.google.com/webmasters/tools/home?hl=en

hope that helps


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>