I'm trying to add a route that will transfer all sitemap.xml
requests to a custom request handler I made.
I tried using the following code:
routes.Add(new Route("sitemap.xml", new Helpers.SiteMapRouteHandler()));
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
But when I make a link using Url.Action()
:
Url.Action("Index", new { controller = "About"})
I get the following when I try to navigate to the XML file:
/sitemap.xml?action=Index&controller=About
What am I doing wrong?
ANSWER:
I used this solution: