Question: I'm trying to pass ViewData to my asp.net mvc masterpage for an mvc usercontrol that I keep on a masterpage. For example, I created a dropdownlist of names as an mvc usercontrol and I put that in my masterpage.

The problem I am running into is passing the ViewData to the masterpage. I found this article from Microsoft which has a decent solution but I was wondering if there are other "better" solutions out there. The thing I don't like about the solution in the link is that I have to change every controller to inherit from a new controller class.

<http://www.asp.net/learn/MVC/tutorial-13-cs.aspx>

**Edit**: The problem I am looking at is the fact that if I place a user control in my masterpage that relies on ViewData, I have to **REPEATEDLY** include that ViewData for every single page that uses said masterpage. It's possible the solution in the link above is the best solution but I was hoping there were other alternatives.

Answer: 
Could you possibly use the `OnActionExecuting` method on a base controller class and populate the view data there?

Something like:

```
protected override void OnActionExecuting(ActionExecutingContext context)
{
  context.Controller.ViewData.Model = GetDataForControl();
}

```

I haven't tried it so it's just a thought...
I usually use an abstract controller class for my MasterPage, it is the best solution, because the MasterPage is like an "abstract view". But I override the MasgerPageController View() method to include the viewdata.

```
protected override ViewResult View(string viewName, string masterName, object model)
{
    this.ViewData["menu"] = this.PagesRepository.GetPublishPages();
    return base.View(viewName, masterName, model);
}

```