I have MVC project.
It works fine, but sometimes it's throws an exception.
Here is an IIS screenshot of error.
object reference not set to an instance of an object
object reference not set to an instance of an object
When the users reload the page, error disappears.
@if (Model.CashboxStatus != null && Model.CashboxStatus.Count > 0)
{
foreach (var item in Model.CashboxStatus)
{
<td>@item.CashboxName</td>
}
}
this is the code populating the Model:
public ActionResult Cashboxes()
{
CashboxesModel model = new CashboxesModel();
model.Cashboxes = CashboxLogic.GetCashboxes();
return View(model);
}
It gives an error on first line.
I have no idea why this error appears. We have about 100 users daily.
Any ideas?