Most elegant way to ensure view model data for _Layout.cshtml

前端 未结 3 1083

In my application I have some basic user information that needs to be displayed on every page (name, profile img). At the moment I have simply set the model in the _Layout

3条回答
  •  日久生厌
    2021-02-04 10:46

    Another option would be to rip out the parts of the layout view that require data, and place them into partials. Then from your layout view make an Html.Action call to actions that return those partials with the necessary viewmodel data.

提交回复
热议问题