I’m using ASP.NET MVC with Razor syntax. I’m trying to find the best way to obtain data and pass that around my application for access by both the layout view (shared) and other views. In some cases, additional model(s) may need to be passed to views. I’ve looked at items like the BaseViewModel, but for that, I’d need to pass a model on every ActionResult that would use it. The data changes for every user and could change during the same session.
What’s the best way to accomplish that?
Create a BaseViewModel and make MyModel a child of this model (ie:
public class MyModel:BaseViewModel). In this BaseViewModel put all the common properties that your layout has to use.After, you need to put in your shared layout: