开发者

asp.net mvc - how to pass more than 1 default paramters when mapping routes

开发者 https://www.devze.com 2022-12-20 17:44 出处:网络
I am trying to pass more that 1 default parameters when mapping a route i.e routes.MapRoute( null, \"items\",

I am trying to pass more that 1 default parameters when mapping a route i.e

routes.MapRoute(
            null, 
            "items", 
            new { controller = "Items", action = "Ind开发者_如何学Cex",  new { page = 1, pageSize=10 } } //prob here
        );

Works fine with 1 parameter like:

routes.MapRoute(
            null, 
            "items", 
            new { controller = "Items", action = "Index",  page = 1 } //prob here
        );

Thanks in advance


You are already declaring three default parameters here:

new { controller = "Items", action = "Index",  page = 1 }

Adding a fourth is as simple as:

new { controller = "Items", action = "Index",  page = 1, pageSize=10 }
0

精彩评论

暂无评论...
验证码 换一张
取 消