1
相关航线的注册代码:ASP.NET路由使用错误的路由来生成URL;路由值成为查询字符串参数
routes.MapRoute(
"QuestionsMostRecent",
"questions",
new { controller = "questions", action = "most_recent" }
);
routes.MapRoute(
"ControllerActionFormat",
"{controller}/{action}.{format}"
);
线路生成代码:
Url.RouteUrl(new {
controller = "questions",
action = "most_recent",
format = "rss"
});
我希望收到“/questions/most_recent.rss”,而是我收到“/问题?格式= RSS”。我意识到我可以通过引用路由名称“ControllerActionFormat”来强制我的预期结果,但我很好奇为什么路由系统与第一条路由匹配。任何人都可以对此有所了解吗?