【发布时间】:2011-11-10 00:51:26
【问题描述】:
我有一个帖子操作导入:
public ActionResult Import()
{
var fileNames = new List<String>();
foreach (string path in Directory.GetFiles(directoryPath))
{
//do a whole bunch of stuff
...
fileNames.Add(path.Split('\\').Last());
}
return RedirectToAction("Index", new { InvalidFiles = fileNames });
}
如您所见,它重定向到 Index 操作,传递文件名的 List<String>
public ActionResult Index(List<String> InvalidFiles)
{
return View();
}
在Index 操作中,List 包含适量的元素,但所有实际字符串已从文件名更改为字符串“System.Collections.Generic.List`1[System.String] ”。
知道为什么会这样吗?是否有更好的方法将列表传递给新操作,可能使用 TempData?
【问题讨论】:
标签: .net asp.net-mvc