sitemap.xml

MVC: How to route /sitemap.xml to an ActionResult?

筅森魡賤 提交于 2019-11-30 06:51:07
I've got a SitemapActionResult that overrides the ActionResult, and delivers a SEO sitemap.xml when http://www.sprelle.no/Home/SiteMap is hit. So far so good. What I would like, though, is to serve the sitemap.xml when Google visits /sitemap.xml. For that to work, I need a route that sees "sitemap.xml" and directs to /Home/Sitemap. How do I create this mapping (in the Routes table)? Add a map for: routes.MapRoute( "Sitemap", "sitemap.xml", new { controller = "Home", action = "SiteMap" } ); Notice that the route, controller, and action options are hard coded. Pablo Andres Barrantes You can used