views:

40

answers:

3

Hello,

I have two web applications in ASP.NET which are quite the same (same business logic, same DAL, same DB scheme but different instance).

The only thing that I need to change is the design (logo, color,...) and the text (global and local resource) to adress two separate business sector. We cannot "subdomain" the application because we need the two app "seems to be" independant.

Is it a good idea to run only one instance for the 2 web applications.

For example :

I will have 2 hostnames : mycompagny.com and mycompagny2.com and I will put an HTTP Module which will set a string which will be propagated in my application like 'company' and 'company2'. I will instanciate the dal only once but the connection string will change depending on the string 'company' or 'company2'.

Any pros and cons ? Any other alternatives ?

[Updated] Just for information it is a Multi-Business and Multi-Tenant application because both application will have custom theme for some parts of the application.

For example :

mycompagny.com/Busineess1, mycompagny.com/Busineess2, mycompagny.com/Busineess3,.. and mycompagny2.com/Busineess2, mycompagny2.com/Busineess2, mycompagny2.com/Busineess3,...

A: 

It sounds like you are describing a Multi-Tenant application. Here is a nice overview of some of the challenges of working Multi-Tenant in ASP.Net. There is actually quite a lot of information being produced recently on Multi-Tenant ASP.Net MVC applications, so that is also worth a look.

ckramer
+1  A: 

Yes this is done all the time..even for large sites.

In ASP.NET, you can parse the Request.Url and determine which content to display or which data to retrieve, depending on the domain name.

When you're instantiating the DAL, you'll have to specify which db you want to connect to.

Ed B
A: 

So at each request, you check the Request.Url, instanciate the DAL and then process your ressources ? I thought that you should instantiate the DAL at Application.Start()...

So How and "where" do you set the config to prevent passing the Request.Url string? I'm a bit worried because instantiate a DAL is a costly process... so is there a future "performance problem" ?

Rick
Yes but I can instantiate the DAL and ofter configure it during the request, like DAL = new DAL(); during the Application.Start() andduring the request, do something like DAL.Context = "mycompagny2";If DAL.Context is empty, this is Compagny1 that will run...
dervlap