I am attempting to create a Multi tenant SaaS site and have been reading a lot of topics around the subject, however there are still some things I'm unsure about.
Most of the examples use
Request.Url.Host
in order to determine the tenant. The question is where is the best place to check the tenant, would this be in theController constructor
or in theglobal.asax
? As this needs to be checked for every request I'm guessing the tenant/host mapping should be stored in a hashtable somewhere?How does IIS and Application Pools fit into all of this, do I still need an IIS site + application pool for each of my tenants but point the phsycial path to the same location? or will I just require a single site + application pool?
For Authentication on each of the tenants sites, I'm guessing we just need to set the cookie to be the tenants domain/subdomain?
HttpCookie cookie = FormsAuthentication.GetAuthCookie(username, true); cookie.Domain = "subdomain.domain.com"
How would you go about caching data for a particular tenant?
HttpRuntime.Cache["CacheData"]
would this cache not be available for every tenant?