MapRoute()无法正常运行

时间:2018-07-25 13:56:21

标签: asp.net-mvc

我需要将Company/Careers/OpenPosition重定向到Company/OpenPosition。为什么下面的MapRoute()调用不起作用?

谢谢。

routes.MapRoute(
            "Company", // Route name
            "Careers/OpenPosition/{action}", // URL with parameters
            new { controller = "Company", action = "OpenPosition" } // Parameter defaults
        );

2 个答案:

答案 0 :(得分:2)

如下所示:

routes.MapRoute( "Company", // Route name 
"Company/Careers/OpenPosition/",
 new { controller = "Company", action = "OpenPosition" } );

routes.MapRoute( "Company", // Route name
"Company/Careers/OpenPosition/{customVariable}",
     new { controller = "Company", action = "OpenPosition" } );

答案 1 :(得分:0)

如下所示:

routes.MapRoute( "Company", // Route name 
"Company/Careers/OpenPosition/",
    new { controller = "Company", action = "OpenPosition" } );

routes.MapRoute( "Company", // Route name
 "Company/Careers/OpenPosition/{customVariable}",
    new { controller = "Company", action = "OpenPosition" } );