考虑以下MVC路由条目:
routes.MapRoute("Content", "content/{route}", new { controller = "Content", action = "ContentPage", route="" });
适用于:
www.domain.com/content/test
www.domain.com/content/blah
也适用于网址参数
www.domain.com/content/test?hello=1
不起作用:
www.domain.com/content/foo/bar
www.domain.com/one/two/three/four
{route}
? 答案 0 :(得分:0)
试试这个,
routes.MapRoute("Content", "content/{route1}/{route2}", new { controller = "Content", action = "ContentPage", route1 = UrlParameter.Optional, route2 = UrlParameter.Optional });
注意:根据需要添加最大数量的可选参数。