我正在尝试创建看起来像这样的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)