views:

146

answers:

1

Hi, 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)?

+2  A: 

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.

bendewey
I actually tried this earlier today, but couldn't get it to work because I added the route _after_ the Default route. It needs to be inserted _before_ the Default route to work. Thank you.
HaakonL