MVC中的路由

 routes.MapRoute(
                "", // 路由名称
                "{controller}/{action}/{id}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
            );
            routes.MapRoute(
                "", // 路由名称
                "{controller}/{action}/{id}/{*name}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = UrlParameter.Optional, name=UrlParameter.Optional  } // 参数默认值
            );

id=UrlParameter.Optional 的意思是说这个参数是可选参数

 routes.MapRoute(
                "", // 路由名称
                "{controller}/{action}/{id}-{other}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = UrlParameter.Optional, other=UrlParameter.Optional  } // 参数默认值
            );

这样写的参数到后台进行拆分。

原文地址:https://www.cnblogs.com/heluo/p/2542135.html