I'm very new to ASP.NET and I'm trying some things out right now. I try to make a simple dashboard right now which displays some set numbers, but I get this System.NullReferenceException The whole day I try to fix this, but it keeps throwing this exception.
index.cshtml:
@model XSP.ViewModels.DashboardViewModel
<img src="assets/images/plane-icon.png" alt="deliver-icon">
</span>
<h2>Errors</h2>
</div><!--/.icon-box-->
<h3>@Model.errors</h3>
<p>0 This Week</p>
</div><!--/.profile-state-->
</div><!--/.col-->
My HomeController where the values are getting filled:
public class HomeController : Controller
{
public IActionResult Index()
{
DashboardViewModel dashboard = new DashboardViewModel();
dashboard.onlineplayers = 1;
dashboard.errors = 222;
return View(dashboard);
}
}
And here's my ViewModel
public class DashboardViewModel
{
public int onlineplayers { get; set; };
public int errors { get; set; };
}
I already checked the other threads before I asked this question where the solution was always in the Controller adding return View(XX); but I have a return value.
Thanks for your help :)
@Model.errors
` – Hakuryuu May 22 '21 at 18:52