Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 703279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:48:49+00:00 2026-05-14T03:48:49+00:00

I am developing a single web application that will dynamically change its content depending

  • 0

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 http://www.clientone.com to 127.0.0.1, and http://www.clienttwo.com to 127.0.0.1. I then browse to the application with the browser using http://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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:48:49+00:00Added an answer on May 14, 2026 at 3:48 am

    Figured this one out on my own. The problem here wasn’t that the HOSTS file didn’t work, it was that I was using the wrong method to detect the host header from the browser.

    This does NOT work, and only repeats the 127.0.0.1 localhost that the ASP development server lives on.

     Request.Url.Host;
    

    However, by using the following instead, the domain entered into the browser is stored and can be used to dynamically change the site behavior, even on the ASP development server.

     HttpContext.Current.Request.Headers.Get("Host").ToString();  
    

    So the solution to test multiple domains on a Dev server is:

    1. create several test domains in the HOSTS file on your local machine pointing to 127.0.0.1
    2. use the Headers.Get(“Host”) syntax to sniff the domain entered into the browser

    The only ‘gotcha’ that I found is that you must still manually preserve the specific port that the ASP dev server is running on.

    Example:
    if you have in your hosts file http://www.mytestdomain.com pointing to 127.0.0.1, and your dev server is running on port 46146, then you must enter the following into your browser for testing: http://www.mytestdomain.com:46146/

    But it still works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web application in which I will have customers and suppliers.
We are developing a SaaS application in Asp.net, where we have used the Single
I am developing a small, internal-use only web application. Given its simple nature and
I am developing a custom CRM solution which will be sold via the Web/SaaS
Background: We are developing a web application that includes charts. Currently one can left-click
I'm developing a multilingual PHP web application, and I've got long(-ish) texts that I
I'm developing a web application that uses PhoneGap:Build for a mobile version and want
I'm interested in developing web application and networking application. For that what is the
I am developing a C# a stand alone single user desktop application that requires
I'm currently developing a MVC3 web application that needs to require extranet users to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.