0

How do you design an ASP.NET MVC site where the "master page" (to use old web forms parlance) needs its own model and the "content area" has its own model. An example of the "master page" model might be the current active category, a bread crumb trail, a login status and the content area might be a grid of product tiles. And if the "content area" needs to know some model data from the "master page" how would that be made available? Most of the examples I can find don't cover this.

tereško
  • 58,060
  • 25
  • 98
  • 150
IanT8
  • 2,167
  • 2
  • 23
  • 38

1 Answers1

0

The master page equivalent terminology is layout page if you are using Razor. What you'll need to do is build up the entity that represents the layout in the controller, and you can pass it some data like this.

Pass data to layout that are common to all pages

You could also leverage the ViewBag dynamic object, which can also be used by the layout, but again the controller has to put data into it.

Community
  • 1
  • 1
Brian Mains
  • 50,520
  • 35
  • 148
  • 257