如何绑定逗号分隔值的查询字符串参数
http://localhost/Action?ids=4783,5063,5305
Run Code Online (Sandbox Code Playgroud)
一个控制器动作期待一个列表?
public ActionResult Action(List<long> ids)
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
注意! ids在控制器动作中必须有一个列表(或基于IEnumerable的东西),所以string ids不被接受作为答案,因为这些参数被传递给许多动作并且将字符串解析为数组会增加不需要的噪声.