I am working on setting up a multi-tenant site, where users can select a theme. Each of these themes have different settings, so I would like someone to be able to select a theme and then when they edit their site settings it would bring up a form to allow that. I am sure I could do this through hard coding data, but it would seem that I would be better off using plugins to allow new theme plugins to be added and remove the need to magic strings or having to create a dynamic settings page that reads what fields to display from a database. There is plenty of documentation on things like MEF, but I need some help on figuring out how to display a unique view for each theme and then store the results. Any help or direction would be appreciated.

  • Do you really need a plugin architecture for this, or would serving a CSS file on a per-user basis suffice? Nov 30, 2016 at 20:14
  • @RobertHarvey Yes, because it is more than just css. Some themes will allow logos or customized feeds.
    – Wade73
    Nov 30, 2016 at 20:38

1 Answer 1


You do not need MEF or plugabble stuff. Using IoC container will be enough for MVC5 I have used Windsor Castle with great success and lately also Autofac.

Then you have all your controllers made by factory and you can have service for selecting layout in your controller. With this service you query database for user settings and set your model/viewbag with needed info. I did something like it for silent release where only pilot users got new look and new features aka feature switch.

Also you can switch your layout by using "_ViewStart.cshtml"

The _ViewStart file can be used to define common view code that you want to execute at the start of each View’s rendering. For example, we could write code within our _ViewStart.cshtml file to programmatically set the Layout property for each View to be the SiteLayout.cshtml file by default.



On finishing note you can also do it with static class that has config from database but then you have to do a lot of ifs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.