Understanding Orchard's Multi-Tenant architecture

Topics: General
Feb 28, 2011 at 9:39 PM

I'm trying to get my head around Orchard's multi-tenant architecture.

The thing I can't seem to pinpoint is how the current site is identified. I can see how the shell for each tenant is created, but I guess I'm expecting to see some code that checks the incoming Url to identify the site (tenant) and load the shell in the first place.

It then looks like the OrchardControllerFactory gets the current WorkContext that presumably is scoped for that tenant (and has access to the underlying IoC container)?

Any additional level of detail would be appreciated.

Thanks

Ben

Coordinator
Feb 28, 2011 at 10:03 PM

You got that pretty much right. I think the missing piece that you're looking for may be ShellRoute?

Feb 28, 2011 at 10:30 PM

So does each tenant effectively have it's own route table?

I was actually looking at the possibility of using Orchard's multi-tenant implementation in another application but I think it's a bit over my head :)

Coordinator
Feb 28, 2011 at 10:36 PM

Yes, I'm pretty sure it does: each tenant may have a different set of modules enabled, each with its own routes.

Mar 2, 2011 at 9:45 PM

Hi Bertrand,

I've spent (more) time looking through the source.

I can see how routes are published, but I can't see how the routes are registered in a tenant specific route table.

It is my understanding that the default System.Web.Mvc.MvcHandler looks in the static System.Web.Mvc.RouteTable collection for a matching route. So how/where are you overriding this behaviour so that the default MvcHandler just inspects the route table (wherever this is) for the current tenant?

I'm getting closer to the aha! moment but I'm not quite there yet :)

Coordinator
Mar 2, 2011 at 11:05 PM

Ah, well, if I understand this correctly routes do not have to be tenant-specific. What will really happen is that the dependency injection will be tenant-specific (thanks to the shell infrastructure). So when the action is geting resolved, only those controllers that are enabled for the current tenant are going to be found, which affects how the route will get resolved. Makes sense?