我正在尝试将路由添加到默认路由,以便我有两个URL工作:
http://www.mywebsite.com/users/createhttp://www.mywebsite.com/users/1这将使第一条路线起作用:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "users", action = "Index", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
但是,第二条路线显然不会起作用.
这将使第二条路线起作用,但会破坏第一条路线:
routes.MapRoute(
name: "Book",
url: "books/{id}",
defaults: new { controller = "users", action = "Details" }
);
Run Code Online (Sandbox Code Playgroud)
如何组合两个路由配置,以便两个URL都有效?如果在SO上已经存在这样的问题我很抱歉,我无法找到任何东西.