create a base class for your controllers which extends System.Web.Mvc.Controller
override the RednerView(ViewContext) method and add your data to viewContext.ViewData.
If you're using strongly typed viewdata then you'll probably what to write a base class for all your view data types which contains the data for your master page.
However, there's a bug with the way the ViewMasterPage<T> works regarding the type of the generic parameter.
tgmdbm
Contributor
4392 Points
883 Posts
ASPInsiders
MVP
Re: MVC - Creating code that runs with every controller action.
Dec 24, 2007 03:05 PM|LINK
create a base class for your controllers which extends System.Web.Mvc.Controller
override the RednerView(ViewContext) method and add your data to viewContext.ViewData.
If you're using strongly typed viewdata then you'll probably what to write a base class for all your view data types which contains the data for your master page.
However, there's a bug with the way the ViewMasterPage<T> works regarding the type of the generic parameter.
Check out the following post for a nice solution http://forums.asp.net/t/1195178.aspx