c# - Where should I edit BaseModelView (in BaseController)? -


i have created base-controller controllers inherit. controller fills data (which use in views) viewdata-container this:

    protected override void initialize(system.web.routing.requestcontext rc)     {         base.initialize(rc);         viewdata["cms_configuration"] = new cmsconfiguration();         // etc.     } 

i don't fact need read (and cast) viewdata within views. i'd introduce baseviewmodel viewmodels inherit from, defining properties instead of using viewdata. how or can populate baseviewmodel within basecontroller? there kind of hook? or need define function in basecontroller, call in child-controller?

e.g. (child-controller:

//{...} base.populatebaseview(myview); return view(myview); 

thx tipps. sl3dg3

you optionally use actionfilters stuff this:

check out article:

http://www.asp.net/mvc/tutorials/understanding-action-filters-cs

it explains actionfilters nicely. way can separate different populate-logic different filters, , turn them on , off please.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -