Asp.net mvc 4 在mvc 4中的routeconfig.cs中设置自定义路径

Asp.net mvc 4 在mvc 4中的routeconfig.cs中设置自定义路径,asp.net-mvc-4,routing,asp.net-web-api,asp.net-mvc-routing,url-routing,Asp.net Mvc 4,Routing,Asp.net Web Api,Asp.net Mvc Routing,Url Routing,下面是我在mvc4应用程序中的routeconfig.cs文件 public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{

下面是我在mvc4应用程序中的routeconfig.cs文件

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{bizId}",
            defaults: new { controller = "Home", action = "Index", bizId = UrlParameter.Optional }
        );

        routes.MapRoute(
            "Outlet",
            "Outlet/{bizId}",
            new { controller = "Home", action = "Index" },
            new { bizId = UrlParameter.Optional }
        );

    }
当我运行应用程序时,我需要输入/Home/Index?bizId=1或本地主机端口后的任何Id来运行我的应用程序。它工作得很好。但是,现在作为第二个route.maproute,我希望url显示为ex:localhost:49787/Outlet?bizId=1,但这不起作用。请帮忙!提前感谢

得到修复:

 routes.MapRoute(
            name: "Outlet",
            url: "Outlet/{bizId}",
            defaults: new { controller = "Home", action = "Index", bizId = 1 }
        );

试着把你的第二条路线放在第一位