小编Adr*_*ian的帖子

路线始终转到第一个maproute

我正在尝试创建看起来像这样的URI: http://hostname/mobile/en/controller/action用于移动设备或http://hostname/en/controller/action用于桌面(非移动设备).

我的路由表目前看起来像这样(Global.asax.cs)

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Mobile", // Route name
            "mobile/{language}/{controller}/{action}/{id}", // URL with parameters
            new { language = "en", controller = "Route", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
            new { language = @"en|us" } // validation
        );
        routes.MapRoute(
            "Default", // Route name
            "{language}/{controller}/{action}/{id}", // URL with parameters
            new { language = "en", controller = "Route", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
            new { language = @"en|us" } // validation …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc routing asp.net-mvc-routing asp.net-mvc-2

5
推荐指数
1
解决办法
1114
查看次数