在我的应用程序中,以下是默认路由
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "WC.UI.Controllers" }
);
现在我希望主页应该是来自某个区域的其他视图所以我在默认路由
的上方添加了bellow route routes.MapRoute(
"MainPage",
"",
new {area = "Contest", controller = "Home", action = "Index"},
namespaces: new[] { "WC.UI.Areas.Contest.Controllers" }
);
所以根据我的默认调用"http://localhost:59616/",它应该去查看这是在区域"Contest",但这里发生的是,它确实去"Contest/Home/Index"的行动,但渲染索引。
尝试给url参数与您所在地区的完整路径,如
url:"AreaName/{控制器}/{行动}/{id}"。