Is there a way that I can pass the same BaseViewModel for every request without returning either the BaseViewModel or something that inherits from the BaseViewModel for each view? I'm usi开发者_JS百科ng a shared view (_layout.cshtml).
No, there isn't a way. If your view or layout is strongly typed to a class BaseViewModel
you need to return an instance of this class (or a derived class) from each controller action that is rendering this view.
As an alternative to the base view model approach you may checkout the Html.Action helper in order to encapsulate some common view functionality.
精彩评论