I am trying to reuse some code and a partial view seems to be the best way to do this when using MVC.
I have created a partial view (see below) which inherits from IEnumerable.
@model IEnumerable<Models.facility>
<div class="display-field">
@foreach (var facility in Model)
{
<li>
@facility.name
</li>
}
</div>
The view that embeds this view does it like so:
<div class="display-field">
<div> @{Html.RenderPartial("FacilityPartial");} </div>
</div>
So now the problem.
I am getting a null reference error and I can see that the Model variable is null.
Error:
Object reference not set to an instance of an object.
Can somebody advise me whether I am doing the correct thing and where I am going wrong other than the fact it is null?