我想从Controller
用户点击和页面中的. 我试过这个,但它给了我一个 404 错误。Home
url
About
Contact
ASP.NET MVC sample application
routes.MapRoute("Home", "{action}/{id}",
new { controller = "Home" });
当我删除这一切都很好。
注意我只想在 Controller 是 Home 时删除 Controller 名称。其他控制器应保持不变。此外,我将代码保存在上面的Route.Config
文件中
routes.MapRoute("Home", "{action}/{id}",
new { controller = "Home" });
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
要求的结果
abc.com/Home/About应显示为abc.com/About
abc.com/Home/Contact应显示为abc.com/Contact