I am building a web application in which there will be a core library and database that is shared by many instances. To give a more concrete example lets say I have a blogging engine and users can sign 开发者_JAVA百科up to their own blog which will act independently of the others on the system.
Each instance must have their own subdomain eg: http://john.extremeblogging.tld/ and also have the option to have their own domain mapped to it eg: http://jonnyblogger.tld/
The problem I have is not knowing how to notify IIS 7.5 what to do when requests come in from either of those domains. Is it as simple as setting this web application to the default site within IIS and the application can use the request headers to take the appropriate action?
It strikes me that this should be a pretty common task so I don't anticipate this to be too difficult to solve but at the moment I am not sure how to approach it.
Any guidance is appreciated.
Thanks
id
Its been very long this question was asked, but still answering it so it might be helpful to others in need.
I happened to work on a big SaaS based multi-tenant project which involved unique subdomains for each of the users site. User could design and manage the content on his own site.
On the registration of a tenant/user we can add domain binding with the IIS using C# following this link-
http://amitpatelit.com/2013/03/12/enter-iis-binding-entry-by-c-code/
Alongside we need to check the host name from the request headers and get the subdomain name to fetch the subdomain specific data and interface etc.
protected override void OnAuthorization(AuthorizationContext filter_context)
{
var url = Request.Headers["HOST"];
var index = url.IndexOf(".");
if(index > 0)
{
var sub = url.Split('.')[0];
FrontSiteData = CommonService.GetSiteData(sub);
}
}
Please let me know if you require more information.
Regards,
Manik
精彩评论