【发布时间】:2012-02-29 20:51:15
【问题描述】:
我有以下路线,在浏览器中输入它们可以正常工作并且路线正确,但如果我使用 Html.ActionLink,它会尝试使用 DefaultStuff 路线。
路线
_routes.MapStuffRoute(
"DefaultStuff",
"stuff/{controller}/{id}",
new { id = UrlParameter.Optional },
new[] { typeof(BaseApiController).Namespace });
_routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { typeof(BaseController).Namespace });
页面
@Html.ActionLink("Job Queues", "Index", "Job") // generates http://localhost/stuff/job?action=Index
我缺少什么让 ActionLink 生成 http://localhost/stuff/index。反转 ActionLink 的路线是正确的,但 Stuff 不起作用。请注意,StuffRoute 根据请求中的信息设置操作名称。
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-routing