问题
I want to create a multi-tenant application that uses the hostname to determine the customer.
For example:
CustomerOne.myapp.com AnotherCo.myapp.com AndOneMore.myapp.com ...
I can do the database and security side with no problems, I can also get the hostname from the URL, but what I am struggling to find out is how to create the basic plumbing that would allow a new customer to sign up online, provide their company name, and for the application to create the new URL, ready to be used straight away.
Can anyone help?
Thanks,
Rob.
回答1:
I can't answer this exactly, but I can break it down a little bit.
To set up a new generic subdomain something.myapp.com you'll need to do two things:
1) Programmatically add some new DNS entries via your ISP so that something.myapp.com points to your web server.
2) Programmatically set the local bindings in IIS so that something.myapp.com gets directed to the right website/virtual directory/application
There is some discussion of setting IIS binding programmatically here, which also links through to this forum post here, which mentions that appcmd.exe can be used to set IIS config at run time.
Hope this points you in the right direction ...
来源:https://stackoverflow.com/questions/2593224/how-can-i-create-and-manage-a-multi-tenant-asp-mvc-application