I am getting a Null reference Exception when I am trying to access from my View to a Model property. 
My View is:
@page
@model WebApp.Pages.IndexModel
<p id="token" style="visibility: hidden;">@Model.Token</p>
My Model is:
public class IndexModel : PageModel
{
    private string token = "token";
    public string Token{ get { return token; } }
    public IndexModel(string token)
    {
        this.token = token;
    }
}
And my Controller is:
public class PopUpAuthController : Controller
{
    public PopUpAuthController()
    {
    }
    public IActionResult Index()
    {
        return View(new IndexModel("TokenPlaceholder"));
    }
}
The @Model.Token is throwing me the exception. I tried to use DataView["Token"] for setting and getting but it throws the same exception.
I have very very simple code but I cant get with this error. I hope you can help me folks.
 
     
     
    
null model
} else { // your code }} – fireydude Aug 16 '19 at 09:45