Question: I am newbie for ASP.NET MVC 1.0. I am converting from a classic application built up with VS2008 .NET3.5. I created a master page, and the menu must be read from the database. Now the code that generate the HTML into the appropriate menu div in classic ASP.NET3.5 VS2008 was in the code behind of the master page.

I cannot understand now where the code beind of the master page is in ASP.NET MVC 1.0?

Anyone has examples?

Thanks

Answer: 
There is a great tutorial on the [ASP.NET site](http://www.asp.net/learn/mvc/tutorial-13-cs.aspx) that shows how to do exactly this.

Briefly, you pass the data to the master page through the ViewData collection. To get the data into ViewData, create an application level controller. Have the page controllers inherit from the application controller instead of the base MVC controller.

Also, if you need to do things on your master page in reaction to the page being displayed, through this application controller you can tie into the ActionExecuting event. That will provide you information about the context of the page request currently being process.
Personally, I prefer using strongly typed views and ViewModels. If your master page requires data, then create a ViewModel for it. Ensure that every page's ViewModel inherits from this base ViewModel. Similarly, create a base controller that every other controller inherits from. Using Action Filters will allow you to ensure that the master ViewModel is populated implicitly. See [this](https://stackoverflow.com/questions/768236/how-to-create-a-strongly-typed-master-page-using-a-base-controller-in-asp-net-mvc) for an example.