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

Viewed 20

When I try to load up my landing page I get a null reference exception and it points to this line of code in my Views/Home/index.cshtml file:

@foreach(var movie in Model.Upcoming.results)

@using MovieProDemo.Models.ViewModels
@model LandingPageVM

@{
    ViewData["Title"] = "MoviePro";
}

<div class="row">
    @foreach (var movie in Model.Upcoming.results)
    {
        <div class="col-sm-3 mb-2">
            <div class="card" style="width: 18rem;">
                <img src="@movie.poster_path" class="card-img-top" alt="Movie Poster" />
                <div class="card-body">
                    <h5 class="card-title">@movie.title</h5>
                    <!--<h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>-->
                    <p class="card-text">@movie.overview</p>
                    <button class="btn btn-lg btn-warning">Details</button>
                </div>
            </div>
        </div>
    }

</div>
0 Answers
Related