我的控制器是“/Home/Index".I想要,当我输入url到”/ Dashboard / Index“或”example.com/Dashboard“时,执行我的”/ Home / Index action method“。你能给我起点吗?
答案 0 :(得分:2)
只需将此路线添加到路线配置中即可。确保在默认路由之前添加:
routes.MapRoute(
name: "HomeRoute",
url: "Dashboard/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);