views:

400

answers:

2

Yet another multi tenancy post im afraid. I just cant find a good solution to my problem, I have read all the great posts on multi tenancy for ASP MVC but I still need some good advice.

Im going to create a corporate presence for one of my customers. Their company structure is like a main company (ex. Acme Group Ltd.) which own several other companies (ex. Acme Holding Ltd, Acme Technology Ltd., Acme Maritime Ltd., etc.).

I want to use one ASP MVC project to serve as the container for all the sites to cut down on the code needed and to keep it DRY. I also want all the sites to use the same Membership DB.

My first thought was to make one controller folder for each sub-company and one root controller for the corporate main page. Then it would look like:

acme.com ("Corporate main page")
acme.com/Holding ("Acme Holding Ltd.")
acme.com/Maritme ("Acme Maritme Ltd.")
...

This structure is fine by me, but I also want the users of the website to access each sub-site based on their own separate domains, ex:

acme-holding.com (This should direct to "acme.com/Holding").
...

That would of course also work, but the thing is that I do not want the url to change when the user is directed to "acme.com/Holding". I would like it to still be "acme-holding.com", "acme-holding.com/About", "acme-holding.com/Contact", etc. instead of "acme.com/Holding/Contact", etc.

What would be the best practice to use in this particular project, any thoughts?

+4  A: 

Keep it simple, use IIS URL Rewrite Module. You can set it up to rewrite acme-holding.com/* URLs to acme.com/Holding/*:

<rewrite>
    <rules>
        <rule name="Forward to acme.com">
            <match url=".*" />
            <action type="Rewrite" url="http://acme.com/Holding/{R:0}" />
        </rule>
    </rules>
</rewrite>
Pavel Chuchuva
I guess i'll go with this combined with DaRKoN_s tip regarding the "areas" in MVC2. Im just wondering if this would be the best practice or should I handle it differently?
Martin
I believe the best practice would be to redirect instead of rewriting. Google doesn't like the same content with different URLs.
Pavel Chuchuva
A: 

I wrote a blog on multi-tenancy that covers exactly what you are attempting here.:

http://jasonjano.wordpress.com/2010/02/22/multi-presentation-websites-for-c/

Good luck!

Jason