Different customers in the same ASP.NET solution

asp.netprojects-and-solutions

I'm having a asp.net website running live with its specific style and specific content. From that site we've built another site with the same logic (in other projects) but with different style and different content (and different files) in the same solution. We've changed the start options from Default.aspx to the root folder for that second site. Now I want to build a more general site which works for several customers, using the same logic and data layers – but with different style and content.

The current site(s) relies heavily on SQL Server 2008 R2, where most of the content resides – but not all. All of the content could be placed in the database with some work if we need to – especially if we get a more general site.

My idea is to use a different start file for every new customer, such as: Default_Customer1.aspx, Default_Customer2.aspx e t c but I'm far from sure if this is the right way to do it. I don't want to have different solutions for every customer. I know that all of the customers will get all of the compiled code, even if some of the code never will be used by that specific customer (who has its specific needs).

So what do I do? Should I try to use different start options (files) for every customer, as mentioned above, or is there a better way handling different customers in the same solution?

Best Answer

Use the same start file for each customer - having one per customer will lead to confusion. What you need is one database per customer.

Create a "pre-login" step where you take the user name and map it to the correct database. So what you have is one ASP membership database that has everybody's login details. This includes an extra table which maps the user to the correct database. So when someone logs in they get the connection string for the correct database. This means you can't have the same user name for multiple sites though.

The alternative is to use separate sub-domains for each customer:

etc.

In this case each sub-domain would have it's own connection string to the database but would mean that you had to deploy the application for each customer though. However, it does mean that you can have the same user name on different sites.