我正在寻找类似于Rails提供的嵌套RESTFul路由功能的路由选项.MvcContrib上的SimplyRestful项目似乎不再是活动的,也不是1.0 MVC版本的最新版本.
这是我正在寻找的uri计划,
/ Activity/10/Task/1/Edit或/ Activity/10/Task/Edit/1
我根本无法让它工作,我遇到的所有文档都描述了非嵌套方案.它似乎并不那么困难......
这就是我一直在努力的...
routes.MapRoute(null, "Activity/{activityId}/Task/{action}/{id}", new { controller = "Task", action = "Edit", activityId = "", id = "" });
Tomas Aschan.. 13
为以下内容添加默认值activity
:
routes.MapRoute(null, "Activity/{activityId}/Task/{action}/{id}/{activity}", new { controller = "Task", action = "Edit", id = "", activityId = "", activity = "" });
还要记住,这条路线只会在表格上提取网址
/Activity/10/Edit/1/theActivity
而你的榜样
/Activity/10/Edit/1
将通过默认路线拾取,将路线值设置为
controller = "Activity" action = "10" id = "Edit/1"
Phil Haack的ASP.NET MVC 路由调试器对于弄清楚如何处理这些事情非常有用......
为以下内容添加默认值activity
:
routes.MapRoute(null, "Activity/{activityId}/Task/{action}/{id}/{activity}", new { controller = "Task", action = "Edit", id = "", activityId = "", activity = "" });
还要记住,这条路线只会在表格上提取网址
/Activity/10/Edit/1/theActivity
而你的榜样
/Activity/10/Edit/1
将通过默认路线拾取,将路线值设置为
controller = "Activity" action = "10" id = "Edit/1"
Phil Haack的ASP.NET MVC 路由调试器对于弄清楚如何处理这些事情非常有用......