I'm setting up a simple ASP.NET Core MVC project that includes some partial views that I want to be rendered asynchronously. But it seems that, regardless whether they are rendered asynchronously or not I keep getting the same ExecuteAsync()
NullReferenceException error.
I have checked all the models and the HTML code but it doesn't seem to work either way, always returning:
An unhandled exception occurred while processing the request. NullReferenceException: Object reference not set to an instance of an object. AspNetCore.Views_Home_Index.ExecuteAsync() in Index.cshtml, line 4.
Index.cshtml:
@using BestDeal.ViewModels
@model HomeViewModel
@await Html.PartialAsync("ArtikalCarouselPocetna")
<h2>Istaknuti artikli</h2>
<div class="row">
@foreach (var artikal in Model.odabraniArtikli)
{
@Html.Partial("ArtikalPregled", artikal)
}
</div>
ArtikalCarouselPocetna partial view:
<div class="row carousel-holder marginTop1">
<div class="col-md-12">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img class="slide-image" src="https://images-na.ssl-images-amazon.com/images/I/71t-J3VJtEL._SX425_.jpg" alt="">
</div>
<div class="item">
<img class="slide-image" src="https://zdnet1.cbsistatic.com/hub/i/r/2019/04/17/1f68c3a6-495e-4325-bc16-cc531812f0ec/thumbnail/770x433/84ff4194826e8303efb771cd377a854f/chuwi-herobook-header.jpg" alt="">
</div>
<div class="item">
<img class="slide-image" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRKRl7BqXfZupIBH4N8i-tD45gVPctFV5jKTeTmOIADFhZ8J_DAYQ" alt="">
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>