Bor*_*ens 6 asp.net-mvc optional-parameters
我可以通过asp.net mvc中的GET请求向动作发送可选参数(空字符串,null int?等)吗?(一句话问题!)
您可以相当轻松地使用路由表执行可选参数,只需在 global.cs 文件的路由中指定默认值即可。
因此,对于带有可选查询和页面的搜索页面,您将拥有类似的内容
RouteTable.Routes.Add(new Route
{
Url = "Search/[query]/[page]",
Defaults = new { controller="Search", action="Results", page=1 },
RouteHandler = typeof(MvcRouteHandler)
});
Run Code Online (Sandbox Code Playgroud)
您的搜索的默认页面为 1。
| 归档时间: |
|
| 查看次数: |
1909 次 |
| 最近记录: |