How to pass the model from the razor page to its master/layout page?
问题 I have a page with following on top: @model AppMainModel @{ ViewData["Title"] = "Home Page"; } I would like to use AppMainModel and its properties in its master/layout page. Strongly typed if possible (e.g. avoid ViewData and the like). Is this possible? 回答1: The ViewModel data is available to the layout page. You can consider having a page viewmodel class with the common data if you want it to be strongly typed in the layout page. If not, simply pass in the common thing using the dynamic