views:

80

answers:

1

I am designing a multi tenants web portal application using MVC.

Tenants will be identified by URL or tenant id. We are going to have a default set of skins and themes but per requirement each tenant can have its own skins and themes.

What is the best way to handle/attach css for multi tenant web portal application?

A: 

How are they going to customize the skins? If it's by substituting a few variables into a a predefined CSS template, then you can save their settings in a database of CSS config values and retrieve them when rendering the page. If they can author CSS from scratch, it might be better to store the CSS as text and then retreive that from the database. That might make testing and debugging CSS a little more difficult.

FrustratedWithFormsDesigner
Let me clarify. All possible css/themes will be defined beforehand. Which css file to use will be defined in the site configurations. We will be using Master Page. Shall I attach the css in master file? My question is what is the best way to attach css for a site? What is the best practice?
AlterWorld
I'm not sure I understand "attach the css in master file"... If all CSS files are defined before, you can associate them with an ID and then in the database for each user, store the ID of their preferred CSS file. When you load that user's page, instead of always loading the same CSS, use the ID from the database to find their preferred CSS. Shouldn't be too hard. If you wanted, you could store the CSS file in the database too, instead of just storing IDs and paths to CSS files.
FrustratedWithFormsDesigner
Thanks, so, the answer is to load the CSS (file it self or path) from the database. Are there any performance issues in loading file from the database?
AlterWorld
@AlterWorld: Possibly, but I doubt you'll hit it with your CSS files (unless you have large CSS files). If you're concerned about that, you could load the files into a lazy-load cache the first time a certain CSS file is requested.
FrustratedWithFormsDesigner