ASP.NET MVC 4核心路由

时间:2013-07-10 12:19:24

标签: asp.net-mvc asp.net-mvc-routing

我为我的网站设置了以下结构。 (见下面的链接) http://postimg.org/image/ut4klihrp/

  • localhost:62540转到核心的索引页面
  • localhost:62540 / www / Home转到WWW的索引页
  • localhost:62540 / cms / Home转到cms的indec页面

我基本上想要'默认' route(localhost:62540)去我的WWW项目。我怎么能这样做,或者有人知道教程是解释这个问题的原则吗?或者这是不可能的,因为我使用区域方法。 最终我想从核心项目中删除视图和控制器。

在www:

中路由配置
routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            namespaces: new string[] { "WWW.Controllers" }
        );

1 个答案:

答案 0 :(得分:0)

您可以在defaults

中指定默认区域
routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { area = "www", controller = "Home", action = "Index", id = UrlParameter.Optional },
    namespaces: new string[] { "WWW.Controllers" }
);