这是由于全球轴心中设定的绕行路线:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
This configures a route with default values for both the controller and action. Thus:
/Home/Index
will match this route with controller and action values explicitly defined
/Home
will match the Default
route and the routing config will supply a default controller of "Home"
/
will match the Default
route and the routing config will supply a default controller and action
You could change this by removing controller = "Home", action = "Index"
from the third argument to MapRoute
. This removes the defaults and requires that the URL explicitly specifies the controller and action.
您希望有第二个<代码>MapRoute,要求明确指明主页路线:
// route the root URL to the home page controller/action
routes.MapRoute("HomePage", "", new { controller = "Home", action = "Index" });
页: 1 不会前往任何控制人员/行动楼梯,你会得到404个,而不是回家。