【发布时间】:2010-04-11 01:19:53
【问题描述】:
如何为项目管理应用程序创建路由结构,其中所有相关部分(例如 TaskController、DocumentController 等)和 Overarching 控制器都有离散控制器。我基本上想要这样的结构:
http://server/Project/123/Task http://server/Project/123/Document
我正在使用 mvc1,因此我无法访问区域等。项目部分将为项目控制器(例如任务、文档等)提供一个单独的母版页,并带有不同的菜单导航。我在 Global.asax 中尝试了三种路线,例如:
routes.MapRoute(
"Task",
"Project/{id}/Task/{action}",
new { controller = "Task", action = "Index", id = "" }
);
routes.MapRoute(
"Message",
"Project/{id}/Message/{action}",
new { controller = "Message", action = "Index", id = "" }
);
routes.MapRoute(
"Document",
"Project/{id}/Document/{action}",
new { controller = "Document", action = "Index", id = "" }
);
我做错了什么
【问题讨论】:
-
是否定义了任何其他可能发生冲突的路由,或者这只是三个路由?
-
调用server/Project/123/Document会得到哪个控制器和动作?
-
Malcolm 你得到 DocumentController 和 Action Index(int projectid)
标签: asp.net-mvc url-routing asp.net-mvc-routing