我在一个ActionResult中声明一个列表,添加到它并通过redirecttoaction传递它以显示但是没有数据,其中abouts是我的语法错误?我已经测试了列表,其中有数据(if语句在循环中):
重定向部分:
var list = new List<FailedView>();
if (Metric[1] == "Failed") { list.Add(new FailedView { domain = Metric[0], reason = Metric[2] });
return RedirectToAction("Complete", new { failedView = list } );
}
查看ActionResult
public ActionResult Complete(List<FailedView> failedView)
{
return View(failedView);
}
模型
public class FailedView
{
public string domain { get; set; }
public string reason { get; set; }
}
}
查看
@model List<Linkofy.Models.FailedView>
<table class="table">
<tr>
<th>
Domain
</th>
<th>
Reason
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.domain)
</td>
<td>
@Html.DisplayFor(modelItem => item.reason)
</td>
</tr>
}