I'm trying to understand how to make partial views. So far I have the following for the partial view, called "_News":
@model Site.Services.News.NewsItem
<div class="bs-callout bs-callout-primary">
<h2>
@Html.DisplayFor(model => item.Title)
</h2>
</div>
And then in the controller I have:
@model IEnumerable<Site.Services.News.NewsItem> - Does this belong here?
...other controller code here...
@foreach(var item in Model)
{
Html.Partial("_News", item);
}
But I'm getting "NullReferenceException" when I try to run the application. What am I doing wrong?
Edit as per comments:
public ActionResult Index()
{
NewsReader newsReader = new NewsReader();
var newsItems = newsReader.GetNewsItems();
return View(newsItems);
}