我需要将字符串列表发送到 asp net mvc Controller 中的方法。我怎样才能做到这一点?
我希望 Controller 中的方法看起来像这样:
public ActionResult CutFile(string[] filenames, string target)
我可以选择将字符串数组参数更改为如下所示:
public ActionResult CutFile(IEnumerable<string> filenames, string target)
最佳答案
您需要以这种格式发送数据:
<input type="text" name="filenames[0]" value="A"/>
<input type="text" name="filenames[1]" value="B"/>
<input type="text" name="filenames[2]" value="C"/>
<input type="text" name="target" />
关于c# - Controller 中的 Asp .Net 方法采用字符串列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14256144/