Why is my Model object always null on my Razor Page in dotnet core 2.x Razor Page app?

If I make one change to the BasicPartial.cshtml file then the Model is no longer null.

All I have to do is remove the @page directive so the BasicPartial.cshtml file now looks like the following:

@model IndexModel
@*
    For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
*@
<div>This is the text and the user name is @(Model.UserName).</div>

Now it works perfectly. The Model object is a the valid object with the property value set as expected. (See highlighted text in the image below.)

model is no longer null


As OP pointed out, removing the @page directive will fix things.

From the docs for @page

@page makes the file into an MVC action - which means that it handles requests directly, without going through a controller.

In other words, your controller wasn't actually being used, despite being called*.
*At least in my case, my controller was called . I did not test OP's code

Certainly a flawed design.