views:

34

answers:

1

I am working on a ASP.NET MVC 2.0 Multi-Presentation web application which would use a common codebase to support different websites. These websites would differ in following aspects:

  • Each website will have their own headers, footers, images, CSS etc (I guess website specific Master Pages)
  • Some of the UI elements could be different based on soft-coded settings at website level

What is the best approach to handle these requirements? Should I be storing these website level soft-coded settings in Database or multiple config files? I might have to provide a admin UI to manage these soft-coded settings. How do I access these settings in different layers (MVC, Services, Repositories etc) of my application?

I need suggestions from experts.

Regards, Alex.

A: 

Develop some sort of Presentation Object Model (or possibly Aggregate if you're DDD inclined) and then persist that to the db. It could be per-user or per-site (if it's a multi-tenanted app you're building) and with MVC it would be easy to build Html Helpers that accept these Presentation Model Objects and render out your customized header, css, images etc.

Potential long-shot practical example:

Let's say your 'tenant' is called a Site - you'll prob have a Site object in your model. A property of Site could be a WebPresentation object. WebPresentation may have a series of child objects and lists with methods for reading css, css files (for <link> elements in the document head), images, etc. You may also have a Service or set of Service functions for persisting/validating the WebPresentation objects (or you may try to have this functionality come off the objects themselves- think .Save()). I won't go into how you persist this data to the db (don't want to insult you). As for the Views, you would design them (perhaps Partial Views) such that the custom WebPresentation Html helpers render the customizations out into the views or <head> sections of your MasterPages.

I hope this example is useful.

cottsak
Thanks Cottsak. Can you pls. elaborate little bit or point me to some article or sample which would help me understand this better? I have my domain model defined which would persist data to DB but I am not sure how to manage (store and retrieve) these per-site specific settings.
Alex
Problem is i don't know if there is a lot of specific examples out there on the net about Multitenancy in aspnetmvc. I'm working on something with similar requirements and that's why my answer seems so conceptual - because i really don't know how exactly this will look.
cottsak
Alex
I use StructureMap as my IoC/DI solution and use the instance caching it provides. This is not the ASP.NET cache (as far as i am aware), it's more like static/singleton memory caching - it's persisted in the IoC Container. Anyway, i have custom 'expiry' methods i can fire when updates/changes are made so it has the effect of single calls to the DB for the data unless the user changes something. You could expand it more to make it more advanced but i hope you get the picture.
cottsak