Home Net Core Inline Razor Markup Null Model

# Net Core Inline Razor Markup Null Model

Tango Down
1#
Tango Down Published in 2018-01-11 18:12:43Z
 My first go with Razor Pages inline markup. Running into this weird issue after passing a ViewModel to a PartialView. Of course in my parent page I pass the ViewModel to the PartialView: @{Html.RenderPartial("Partial/_RequestView", Model.NewRequest);} public class IndexModel : PageModel { private readonly IActiveDirectoryClient _activeDirectoryClient; private readonly ITravelClient _travelClient; public IEnumerable Requests { get; set; }  In the partial view, I have no issue referencing the model in a lambda expression @Html.HiddenFor(model => model.RequestId)  However when I attempt to reference the Model in razor markup inline the Model is null. Any ideas? 

@Model.Name

 The NewRequest property is set within the OnGetAsync() method in the parent page  public async Task OnGetAsync() { NewRequest = BuildNewRequest(); if (NewRequest == null) throw new NullReferenceException("Unable to build new travel request"); return await Task.FromResult(Page()); } 
Tango Down
2#
Tango Down Reply to 2018-01-16 16:45:26Z
 Answered my own question. MUST remove the @page directive in order for the partial view to work and for the @Model to be recognized. Kinda bizarre that VS 2017 templates adds this directive for a partial view, I can only assume it's a bug.
 You need to login account before you can post.
Processed in 0.31818 second(s) , Gzip On .