I use strongly typed views where all ViewModels inherit a class BaseViewModel.
In an ActionFilter that decorates all Controllers I want to use the Model.
Right now I can only access it like this:
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
ViewModelBase model = (ViewModelBase)filterContext.ActionParameters["viewModel"];
base.OnActionExecuting(filterContext);
}
The problem is, that I have to know the key "viewModel". The key is viewModel, because in my controller I used:
return View("MyView", viewModel)
Is there a saver way to acces the Model?