I've seen this code a ton on this site, but I can't seem to get it to work. When I navigate to www.mysite.com/sitemap.xml it gives me a 404 error. Here is my code for the RouteTable
setup:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.RouteExistingFiles = true;
routes.MapRoute(
"Sitemap",
"sitemap.xml",
new { controller = "Home", action = "SiteMap" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
Here is the Global.asax:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
Would someone please point out what I've done wrong? It looks like the examples given in questions such as C# mvc3 redirect sitemap.xml to controller action.