2

我想将我的 url 中的字符串传输到 mvc 控制器。

我的控制器方法是

public ActionResult Index(MyModel model)

我希望我的模型是

public class TagEditRequestVM
{
    public string ValueA { get; set; }

    public List<string> MyList { get; set; }
}

调用它的最佳 url 结构是什么?

4

1 回答 1

3

您必须使用索引和 [] 表示法:

http://host/Controller/Index?ValueA=val&MyList[0]=item1&MyList[1]=item2

索引不必是递增的整数——它必须是唯一的。

编辑

好的,感谢 plurby 在他的评论中写的链接,您可以省略括号符号并重复属性名称:

http://host/Controller/Index?ValueA=val&MyList=item1&MyList=item2
于 2013-05-07T07:46:12.800 回答