Test multiple domains using ASP.NET development server

Posted by Pete Lunenfeld on Stack Overflow See other posts from Stack Overflow or by Pete Lunenfeld
Published on 2010-03-25T05:15:18Z Indexed on 2010/03/25 5:23 UTC
Read the original article Hit count: 325

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about visual-studio-2008