I create a baseviewmodel that my other strongly typed view models inherit from.
BaseController:
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
var baseViewModel = ViewData.Model as BaseViewModel;
if (baseViewModel != null)
{
// set common properties that I want to use in all views
}
}
Now when I set a breakpoint on the if cluase, it seems baseViewModel is always null.
How do I set the base ViewData.Model to be of BaseViewModel?
OnActionExecuting is too early to look at the model.
Called before the action method is invoked.
You can see model in OnActionExecuted.