per client master page separation
On the current project I'm working on we are developing a product that eventually gets used at various different client sites. At the moment the way things are done is that all code for all of the clients is included in the one solution, currently there's only about 5 or so clients so its manageable but I'd like to reorganize this so we can move these bits out to client specific areas.
In regards to the actual assemblies for various clients I think we can easily achieve something flexible using MEF or IOC.
The area im not sure about is the web side of things. Each client current has their own master page and these master pages are fairly radically different, apart from having the same content areas, the customization is probably not able likely to just be achieved by pure CSS.
Is there a way to have a "base" masterpage that would normally get used and then if we want to deploy to client A we can 开发者_StackOverflowjust inject somehow client As master page. Currently this is handled by all of the content pages referring to Master.master as their master page and then there is a generic Master.master, when deploying to client A we rename Master.master to something and rename the specifically tailored master page for client A (ClientA.master) to Master.master and deploy.
The down side to all of this is that all of the master pages are kept in the one web project which feels a bit wrong if we are trying to head to a client agnostic main branch, and unless the other master pages are deleted as part of the deployment the client would get a copy of them on their server even though they aren't used and preferrably we'd not like to have one client being able to switch to another clients view etc (not that security wise it would have any effect)
Have you checked out Themes. We have used themes for this sort of thing before.
If that does not have enough power for you you can do what you want in the pre_init phase. We use this code in some places
protected void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = "~/page.master";
}
You can of course use logic to determine what master page you wish to use.
精彩评论