【问题标题】:Routing with command controller and sub controllers without using areas在不使用区域的情况下使用命令控制器和子控制器进行路由
【发布时间】: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


【解决方案1】:

使用路由调试器看看哪里出了问题http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-31
    • 2014-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多