I have an ASP.NET Core MVC application and in my Get handler data is passed to the view. However in my view the model is empty.
When debugging and checking over the data, the count of the IEnumerable<Trip> = 2
. The data is then passed as a parameter in return View(data);
.
When I iterate through the IEnumerable
using razors @foreach
clause I get a
NullReferenceException
Because the model is empty.
Screenshot of the action method:
Screenshot of my razor view:
I have done research and I have seen questions here in which the data was not passed as a parameter in the return View()
. For as far as I can tell all is done well in my case.