1

// global.asax 路由

routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string[] { "MyApplication.Controllers" } // Controller Namespace
);

// 区域注册路由

context.MapRoute(
MyArea_default,
"MyArea/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new string[] { "MyApplication.Areas.MyArea.Controllers" }
);

当我去http://mydomain.com/controler_in_area仍然工作。如何禁用http://mydomain.com/controler_in_area,我只想作为http://mydomain.com/MyArea/controler_in_area工作

4

2 回答 2

2

我已经尝试使用您的代码为我工作。见下面的截图。在此处输入图像描述

在此处输入图像描述

于 2013-09-28T06:56:24.430 回答
0

在默认路由之前注册 MyArea_default 路由。路线先匹配,先匹配。

于 2013-09-28T10:55:09.917 回答