2

下面是我在 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 }
        );

    }

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

4

1 回答 1

2

得到了修复:

 routes.MapRoute(
            name: "Outlet",
            url: "Outlet/{bizId}",
            defaults: new { controller = "Home", action = "Index", bizId = 1 }
        );
于 2013-05-30T12:59:38.213 回答