0
我想在MVC中設置自定義路由,但有幾個問題。MVC路由不按需要工作
這是配置文件至今: -
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "inbox",
url: "inbox",
defaults: new { controller = "Mail", action = "Inbox", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
這是我認爲的鏈接: -
@Html.ActionLink("Inbox", "inbox")
麻煩的是輸出HTML是被生產爲http://localhost/Home/inbox
我只希望它是http://localhost/inbox
謝謝他任何他lp
好男人,工作! – Shazoo