我想添加一個路由,將所有sitemap.xml
請求傳輸到我所做的自定義請求處理程序。轉移sitemap.xml HTTP請求到ASP.NET MVC中的路由處理程序
我用下面的代碼嘗試:
routes.Add(new Route("sitemap.xml", new Helpers.SiteMapRouteHandler()));
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
但是當我提出用Url.Action()
鏈接:
Url.Action("Index", new { controller = "About"})
我碰到下面當我嘗試導航到XML文件:
/sitemap.xml?action=Index&controller=About
我在做什麼錯?
答:
我用這個解決方案:
Specifying exact path for my ASP.NET Http Handler
你在哪裏有它在你的路由列表?它看起來很通用,所以它會匹配所有請求。你可能想用Phil Haack的Route Debugger來幫助你。 – 2011-02-07 15:58:42