I wrote multi-tenant web application in MVC2. Adding / Removing an account is as complex as adding / removing a row in a table as I opted for shared database, shared schema approach.
This is a very good article about multi-tenant database design from MSDN: Multi-Tenant Data Architecture
All I had to do in MVC is to set up routing properly, so the first part of the path is account name:
- www.yourdomain.com/Account1/...
- www.yourdomain.com/Account2/...
- www.yourdomain.com/Account3/...
and I have a custom MvcHandler for looking up account for each request:
public class AccountMvcHandler : MvcHandler
{
public AccountModel Account { get; set; }
public AccountMvcHandler(RequestContext requestContext)
: base(requestContext)
{
}
protected override IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object state)
{
string accountName = this.RequestContext.RouteData.GetRequiredString("account");
Account = ServiceFactory.GetService<IAccountService>().GetAccount(accountName);
// URL doesn't contain valid account name - redirect to login page with Account Name textbox
if (Account == null)
httpContext.Response.Redirect(FormsAuthentication.LoginUrl);
return base.BeginProcessRequest(httpContext, callback, state);
}
}
As it was said by Andreas Paulsson the key phrase is "custom assemblies". Why do you need 'custom assemblies' for configuration? Are you using CodeEmit? Will users upload them? I would rather think about using Windows Workflow Foundation for any client-specific business logic customisation.