I've implemented a sitemap that is dynamically generated on the fly using the technique described here.
Since my site is a WebForms app, my sitemap URL ends up being www.mydomain.com/Sitemap.aspx.
This is working well, and I can use search engine webmaster tools to tell them the URL to my sitemap. However, smaller search engines may not know where to find this file. It would be better if my dynamically generated sitemap could be at www.mydomain.com/sitemap.xml. This is the standard URL for a sitemap.
What is the easiest way to generate the same sitemap data I do now but have it appear as the file sitemap.xml. Can I do it using routing, or do I need a custom HTTP handler?
I'm using webforms but also have sites using ASP.NET MVC so I'm very interested in finding the best technique to do this in both platforms.
For Webforms, you can use HttpModule, check out UrlRewriting.NET
For MVC, use routing:
routes.MapRoute("Sitemap",
"sitemap.xml",
new { controller = "Home", action = "Sitemap" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With