2

I have a _Layout file that contains this. The _HeaderModel class gets initialized correctly.

<partial name="_Header" model='new _HeaderModel((int?)ViewData["ActiveIndex"])' />

_Header contains

@page
@model Project.Pages.Shared._HeaderModel
@Model.ActiveIndex

I get this error:

'Model' threw an exception of type 'System.NullReferenceException'

Model isn't even a null reference; trying to access the property throws this exception. I really can't do it any more basic. What am I doing wrong?

Edit: This has nothing to do with the generic NullReferenceException thread. I know what a NullReferenceException is (duh) but why would it be happening here? This is a very specific case that regards ASP.NET Core 2.

Liam
  • 22,818
  • 25
  • 93
  • 157
Etienne Charland
  • 2,175
  • 2
  • 17
  • 37

0 Answers0