Sometime ago I asked this question and I was told that the entry has to be made in DNS etc. I was not sure whether all this is really required or not. The kind of feature that I am looking for is shown in the screenshot below:
As you can see blogger lets the user choose the subdomain for his blog. How can we achieve this? I am basically developing in asp.net C#. How can I allow my users to choose subdomains like this once I have my top level domain. Currently I am developing on localhost.
Setting Up a Subdomain for BloggerView your domain setting options by clicking the "Custom Domain" option beside Switch To. Blogger initially offers you the option to purchase a domain; click the "Switch to Advanced Settings" link to use your own domain. Fill in your Blogger URL.
A subdomain is a prefix added to a domain name to separate a section of your website. Site owners primarily use subdomains to manage extensive sections that require their own content hierarchy, such as online stores, blogs or support platforms. Subdomains function as a separate website from its domain.
In the Subdomain field, place an asterisk * symbol there signifying that you are creating a wildcard subdomain. Choose the domain you want to create a wildcard subdomain for in the Domain section. The Document Root field will automatically generate a path for your wildcard subdomain. You can change the path as needed.
Use a wild card domain in IIS so it traps every request to the top level domain and under.
In asp.net: Create an HttpModule... this will run for every request and you can check the domain name, etc and pull in user information based on the sub-domain. An example httpmodule can be found at URL Rewriting in ASP.NET via HttpModule.
In asp.net mvc: Create a custom RouteHandler (custom based on interface IRouteHandler). Look at RouteHandler vs ControllerFactory question for an example.
You need to add a wildcard DNS mapping that maps *.example.com
to your webserver, and a wildcard hostname mapping telling IIS to send all subdomains to your ASP.Net website.
You can then check Request.Hostname
in server-side code and use the appropriate content (or error message)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With