tags:

views:

34

answers:

1

Hey Guys

I've got a BaseController that all of my site's controllers inherit from.

I've got a BaseModel that all of my Models inherit from.

I want to set my BaseModel in my BaseController's OnActionExecuting method and make it available to the specific model in the specific controller.

Is something like that possible?

Mustafa

A: 

Something like this?

 protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            filterContext.Controller.ViewData.Model = new BaseViewModel();;
        }
Malcolm Frexner
That works - I had to modify my constructor for the derived classes so that it takes an instance of the base class to inherit from for the models that needed some of this shared info.
Mustafakidd