Reputation: 4951
This is my controller that return list of my objects:
public ActionResult ShowList(string site)
{
var list = db.Objects.Where(x => x.protocol == site).ToArray();
ViewBag.Files = list;
return View();
}
Index.cshtml:
@model IQueryable<AutomationCapturesMVC.Models.Capture>
@{
ViewBag.Title = "ShowList";
}
<table>
@foreach (var item in Model)
{
<tr>
<td>@item.fileName</td>
<td>@item.browser</td>
</tr>
}
</table>
Currently get an NullReferenceException
I have checked and the return list ins't empty
Upvotes: 1
Views: 10123
Reputation: 6499
You have to return your list
in param of View()
method :
public ActionResult ShowList(string site)
{
var list = db.Objects.Where(x => x.protocol == site).ToList();
return View(list);
}
Hope it helps
Upvotes: 4