Asp.net mvc 2 ASP.NET MVC 2分页路由问题
我在分页时出错 我的行动:Asp.net mvc 2 ASP.NET MVC 2分页路由问题,asp.net-mvc-2,paging,Asp.net Mvc 2,Paging,我在分页时出错 我的行动: ProductList(string country, string city, string town, int? pageNumber) 我的路线: routes.MapRoute( "ProductList", "myList/{country}/{city}/{town}/{pageNumber}", new { controller = "Product", action = "ProductList", country="", c
ProductList(string country, string city, string town, int? pageNumber)
我的路线:
routes.MapRoute(
"ProductList",
"myList/{country}/{city}/{town}/{pageNumber}",
new { controller = "Product", action = "ProductList", country="", city="", town= "", pageNumber = UrlParameter.Optional });
行动链接:
Url.Action("myList","Product", new{ country="Finland",city="",town="",pageNumber=2 })
城市=2
我找到了如下解决方案:
Url.Action("myList","Product", new{ country="Finland",city="s",town="n",pageNumber=2 })
http://myList/Finland/s/n/2
ProductList(string country, string city, string town, int? pageNumber)
{
city== "s" ? city = null;
town == "n" ? town= null;
process...
}
http:
/myList/芬兰/2
/myList/芬兰/赫尔辛基/3
/myList/Finland/town/7您不能跳过该路线中的参数。您不能打电话期望pageNumber的值为2。将第一段中的值指定给管线中的第一个变量。所以2被分配给城市变量。您必须确保pageNumber之前的所有参数均为非空值。只有路由定义中的最后一个参数是可选的。这与“mvc”无关。也许是关于某个特定的MVC框架?