c# - Best approach to switch PartialView result that is displayed based on configuration -


so right if want change partial view display on page based of off configuration follow:

config item: <add key="instanceowner" value="companyname" />

call render partial view:

 <div id="" class="sidebarbox side-box3">       html.renderaction("productfeature", "dashboard");  </div> 

controller actionresult:

[outputcache(duration = 1)] [validateinput(false)] public actionresult productfeature(string viewname = instnaceowner+"productfeature") {   return partialview(viewname); } 

i name partial views using naming convention companyname-productfeature, companies name variable. doing way feels wrong , inefficient. i'm still new .net mvc though , want know best approach is,thanks!

the plan change value of configuration key if i'm having change instance (which customer) app being used for

based on comment simple reading config value , use determine view show. don't need accept parameters controller method.

public actionresult productfeature() {     var prefix = configurationmanager.appsettings["instanceowner"];     return partialview(prefix+"productfeature"); } 

Comments