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 using a shared view (_layout.cshtml).
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there isn’t a way. If your view or layout is strongly typed to a class
BaseViewModelyou 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.