Test multiple domains using ASP.NET development server
- by Pete Lunenfeld
I am developing a single web application that will dynamically change its content depending on which domain name is used to reach the site. Multiple domains will point to the same application. I wish to use the following code (or something close) to detect the domain name and perform the customizations:
string theDomainName = Request.Url.Host;
switch (theDomainName)
{
case "www.clientone.com":
// do stuff
break;
case "www.clienttwo.com":
// do other stuff
break;
}
I would like to test the functionality of the above using the ASP.NET development server. I created mappings in the local HOSTS file to map www.clientone.com to 127.0.0.1, and www.clienttwo.com to 127.0.0.1. I then browse to the application with the browser using www.clinetone.com (etc).
When I try to test this code using the ASP.net development server the URL always says localhost. It does NOT capture the host entered in the browser, only localhost.
Is there a way to test the URL detection functionality using the development server?
Thanks.