RouteTable Redirect for SiteMap

GodLike

New Member
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 \[code\]RouteTable\[/code\] setup:\[code\]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 } ); }}\[/code\]Here is the Global.asax:\[code\]protected void Application_Start(){ AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles);}\[/code\]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.
 
Back
Top