Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create subdomains programmatically in ASP.NET?

Is there any way to create subdomains via code and route them to my main domain?

product123.domain.com instead of www.domain.com/products/?id=123

like image 617
Mertez Avatar asked Oct 29 '12 23:10

Mertez


People also ask

How do I create a subdomain in a subdomain?

Creating sub-subdomain To create a sub-subdomain, fill up the same form, enter the name you want to use, in this example we will be using sub2. Now on the dropdown menu, select the subdomain you have created earlier, sub1.yourdomain.com. After selection, click on 'Create' button and that's all.

Can you make your own subdomain?

Rather than registering a new domain name, you can always create a subdomain using your existing domain name. A subdomain is an addon to your primary domain with its unique content. It is a separate part of your website that operates under the same primary domain name without you purchasing a new domain.


1 Answers

We do the same thing, but do not generate the DNS records with code. Instead we create a wildcard DNS entry, resolving all subdomains to a given IP. Inside code, we retreive the subdomain from the request URI and use it for further processing.

We use Route53 DNS by amazon, and have an A entry like this

*.ourblogsite.com 184.5.5.5

Which resolves all subdomains to that IP address. Inside IIS we bind an application to port 80 of that IP rather than hostname, which will handle any requests. The Web application is an MVC application, which breaks apart the request URI and fishes the subdomain portion out. We use this to power the somename.ourblogsite.com functionality, where somename is a unique identifier given by the client.

like image 103
mellodev Avatar answered Nov 15 '22 13:11

mellodev