【发布时间】:2018-11-11 10:15:06
【问题描述】:
我正在使用这个路由配置:
routes.MapRoute("Default23",
"{category}",
new { controller = "Product", action = "List", page = 1 }
);
这里是控制器方法:
public ViewResult List(string category, int page = 1)
{
}
但是,如果我使用:
http://localhost:44123/chess?page=2
然后我看到 page=1 (不是 2 ,正如我所料):
顺便说一句-如果我将路线更改为:
routes.MapRoute("Default23",
"{category}",
new { controller = "Product", action = "List" }
);
然后我确实看到了正确的值:
为什么会这样?如果我不设置值,我只想设置一个默认值 . 为什么设置默认值会阻止读取查询字符串值?
【问题讨论】:
-
@Hooman,这不是 OP 所要求的 - 你可以考虑撤回接近投票
-
@StephenMuecke,谢谢...我以为this answer 解释了问题...
标签: asp.net-mvc asp.net-mvc-routing