Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

model null

$
0
0

I'm working on my first core app and running into an issue.

I have a partial, that all it's going to do is show some records from a table in the view

View Code:

@model List<Cars.New.AllMakes>

@{
   foreach(var c in Model)
   {
     <li class"'car-items">
         @c.CarMake</li>

   }

}

I only want to see the CarMake listed. 

I get the following error:

NullReferenceException: Object reference not  set to an instance of an object

    10. foreach(var c in Model)

I have something similar in an MVC 3. app partial. Is it different in CORE? I have no code in the controller, just want to pull from the model. I'm using EF. Do I need to add a GetCars() in the controller? 


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>