I'm trying to refactor several views by moving duplicated code into a partial. However I'm getting several errors, implying that the view doesn't understand the Model data that I'm passing through.
This is how I'm calling the partial from the parent view:
And this is the line in the partial that's causing problems:
<div class="header-title" @Html.DxaPropertyMarkup(() => @Model.PageDetails.PageTitle)>
The line works fine when it's in the parent view, but when it's in a partial I get this error:
...\_HeroBanner.cshtml(19): error CS1963: An expression tree may not contain a dynamic operation
Am I missing something? I'm very new to .NET so this may be an easy fix. I can supply complete code samples if necessary.
Edit: It works if I specify the same model as the parent uses, but this only works in a specific instance. This is insufficient, as the partial needs to be called from several different parent views, which all use different models. Is this possible?