Dofactory.com
Dofactory.com
 Back to list
Views:   24.6K
Replies:  1
Archived

Programmatically create subdomains on IIS with ASP.NET MVC

So, here are my requirements. I am building a multi-tenant site where companies after they sign up get their own subdomain.
Assume that my business is called Email Jobs Inc with domain www.emailjobs.com.  This site is hosted in a shared ISP environment so I have very limited access to IIS etc.

Just to clarify, here is an example of what I need:

company1 signs up and they get this url  company1.emailjobs.com
company2 signs up and they get this url  company2.emailjobs.com
company3 signs up and they get this url: company3.emailjobs.com

My understanding is that there is a DNS and IIS component to this. That is, I will need to change an entry in a DSN server and then also a binding in IIS.  All this is very tricky, because of non-static IP addresses, etc. etc.

However, another option I heard of is to ask your ISP to setup an IIS wildcard option where *.emailjobs.com goes straight to my ASP.NET MVC server. There I can parse the URL, extract the subdomain and I would be in business!  Right?  

Could someone confirm that this is possible and correct? 

I realize that another option I have is to build urls like this: www.emailjobs.com/company1 etc, but that would be far less elegant.
Any feedback would be greatly appreciated...

Best.

Ian Barrymore, Apr 18, 2011
Reply 1
Ian,
I guess you are on right track...see this for setting up zone at DNS server using wildcard

http://technet.microsoft.com/en-us/library/cc288031%28office.12%29.aspx

this way you get all incoming requests for
 company1.emailjobs.com
 company2.emailjobs.com and so on to a specific website created on IIS - make sure you dont have host header with website name and only with IP address.

And use IIS redirect or MVC or traditional web form to intercept request at code level and serve request...

Happy programming
Saurin
Saurin Travadi, Apr 21, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.