I was expecting that to have been fixed in preview #2 (see http://forums.asp.net/t/1195178.aspx for CTP #1 workaround).
Looking at the source for ViewMasterPage<ViewData> (from http://codeplex.com/aspnet):
public class ViewMasterPage<TViewData> : ViewMasterPage {
public new TViewData ViewData {
get {
ViewPage<TViewData> viewPage = Page as ViewPage<TViewData>;
if (viewPage == null) {
throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, MvcResources.ViewMasterPage_RequiresViewPageTViewData));
}
return viewPage.ViewData;
}
}
}
This has been rewritten, but still does not handle the case where the type parameter of the master page is a base class of the type parameter of the page.
I can't understand why there is an attempt to case the page, I would have expected a direct cast of the ViewData member of the ViewContext:
public class ViewMasterPage<TViewData> : ViewMasterPage {
public new TViewData ViewData {
get {
TViewData viewData = ViewContext.ViewData as TViewData;
if (viewData == null) {
throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, MvcResources.ViewMasterPage_RequiresViewPageTViewData));
}
return viewData;
}
}
}
You can either (a) modify the source and compile your own System.Web.Mvc.dll, or (b) create a shim class like in the thread above that fixes the ViewData property.