ASP.NET - how to create subdomain in by code

Asked By Reena Jain on 30-Jan-10 03:27 PM

For eg I am creating one site , and in site if some one registered himself , then a subdomain should generate with his name and country like if user name is abc and country is india . so it should be
How its possible to do it by code.

thanks in advance

Robbe Morris replied to Reena Jain on 30-Jan-10 06:25 PM

You still need a DNS entry on the primary DNS server that manages your domain.  Are you managing your own DNS server?  If not, you have to make arrangements for someone to add the entries for you.

Then, you can add the host header entries in IIS fairly easily.  Some of the code you'll need is in this article.

mv ark replied to Reena Jain on 30-Jan-10 09:16 PM
An alternative to implementing subdomain prefixes by configuring them on the DNS servers 
hosting your domain name is to create fake subdomain addresses with URLrewriting.

URLRewriting at the IIS level can be done using ISAPI filters. Check out these 2 -

URL Replacer -

ISAPI_Rewrite Lite is a free & powerful URL manipulation engine based on regular expressions to alter or obfuscate URLs. Check -

Also check this thread -