I have an MVC4 project that deals with "Courses". Many pages throughout the app need to deal with a list of Courses - user profiles need to pull up the list, the Index view for /Courses needs to pull the list, etc.
Since this data is pretty much always required, I'd like to load it as part of the initial request, so I only have to query the DB one time.
I imagine a scenario where the data gets placed in Layout.cshtml, and then other views can access the Model data as needed, though I don't see a clear way of achieving this. I think I can break the problem into two pieces:
- Get the data loaded into Layout.cshtml
- Access this data from other views
I'm a bit stuck on both - how can I make this work?