سؤال

It has now become a requirement that my existing project requires a different 'theme' for different clients. I have never had to do this on an ASP.NET MVC project and it doesn't seem like ASP.NET Theming and MVC go together very well.

I would say that 75% of the CSS will remain the same with the rest being changeable. It wouldn't have to be able to switch on-the-fly as they will be deployed as separate web sites (probably on different servers).

Just wondering if there was a preferred method for doing this sort of thing? I was thinking of just having a base CSS with separate 'client-specific' ones with overriding rules. The client css name could then be be set in the web.config and brought through to the master page for declaration.

Am I on the right track there?

هل كانت مفيدة؟

المحلول

We do this, with a similar approach as the one you described. Base CSS is always loaded, and CSS overrides are applied depending on the client.

The difference is that we don't use an appSetting, though you could. All of our clients are on the same server, so we manage it using a cookie. When a user signs in, we take the part after the @ symbol in their email address and set a cookie corresponding to the client ID. Our CSS overrides are in a folder with the same name as the client ID.

We then have a child action that renders the additional CSS overrides in the head section, based on the cookie value.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top