I am trying to develop an asp.net site with multiple subdomains. I am new to web sites in general, and asp.net in particular. However, it seems that wildcard subdomains are properly setup with a combination of dns entries and web server configuration - which isn't going to happen on my development machine. Therefore I'm manually inserting entries in my windows hosts file:
127.0.0.1 localhost
127.0.0.1 abc.localhost
127.0.0.1 xyz.localhost
However, when I try to interrogate the Request.Url property there is no subdomain to be seen. For example, if I hit http://abc.localhost:1660/
in the browser I get http://localhost:1660/
from Request.Uri.ToString()
; the abc
is just gone?!
I don't know why the hosts file works like this, but is there any other method I can use to get subdomains into my local web application? Thank you all.
Note that I'm only using the built-in asp.net development server rather than a full iis server. (I can't get access to a full IIS this weekend, but I would still like to know if that would help.)
localhost is not supposed to have any subdomains. To do so violates the approved RFC standards. localhost has an A record and in IPv6 environments, an AAAA record. All other DNS record types, including SOA are forbidden.
Accessing the Subdomain MenuLog in to your Just Host cPanel account. Click the Domains tab at the top of your account. Click On Subdomains on the submenu.
A subdomain contains a second name before the SLD. For instance, if the Themeisle blog was hosted on https://blog.themeisle.com , the blog would be the subdomain.
Don't know about the headers, but one little-known trick that I've used is that all of the 127.* addresses are localhost addresses, not just 127.0.0.1. You can actually run one server listening on 127.0.0.1 port 80, and another webserver instance listening on 127.0.0.2 port 80. So then you'd name 127.0.0.1 localhost, 127.0.0.2 could be abc.localhost (or abc.mydomain.com so you can test the real live URLs against your local webserver), etc.
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