2010-02-20 89 views

回答

8

注意:不确定关于Best,但这是我使用的。

您可以通过使用相同的名称参数为所有的人:

对于URL

http://localhost/MyController/MyAction?a=hi&a=hello&a=sup

你将采取的参数为一个字符串数组(或列表)。

public ActionResult MyAction(string[] a) 
{ 
    string first = a[0]; // hi 
    string second = a[1]; // hello 
    string third = a[2]; // sup 

    return View(); 
} 

这适用于POST和GET。对于POST,您将命名<input>控件的所有相同名称。

+0

+1:很酷。 – 2010-02-20 19:11:24

+0

这看起来不错。但是,是否有可能使用Html.RouteLink生成这种类型的URL? – Shameem 2010-02-21 17:13:48

+0

在ASP.NET MVC中是否存在这种类型参数的名称? (帮助在谷歌搜索更多关于此) – Shameem 2010-02-21 17:15:30

相关问题