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: 
The master page already has access to the ViewData. If you want strongly typed access to it, you need to do two things:

1. Put the master page stuff in a base class (e.g. CommonViewData)
2. Have you master page inherit from the generic ViewMasterPage<> class:

" %>
I don't quite get your problem...

> 
> 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.
> 
> 
> 

Well yeah... of course you do. If you have a usercontrol in your master page then of course you're going to have to pass the required data for that usercontrol for every action & view that uses that masterpage.

It's not like you have to repeat yourself if you are just inheriting from a base controller.

Is your issue the fact that some controllers have actions that both do and don't call views that derive from that particular masterpage? So therefore if you are implementing a base controller, the actions that don't use that particular masterpage will still have the viewdata for it...? (If all that makes sense ;-)