Question

Is it possible to spoof a host for testing?

The site that I'm working on is set up to detect the requested url and render branded assets. So for instance, www.aaa.com and www.bbb.com both point to my web app, but it detects that www.aaa.com was requested, so it loads the correct assets for that brand.

The problem is that I don't know how to effectively test this. My first instinct was to just add www.aaa.com to my host file and have it resolve as 127.0.0.1:64099 (for instance), but you can't specify ports. How else can I go about this without actually having to publish to IIS or a site running on port 80?

Was it helpful?

Solution

You can just add both urls to the host file. Port does not need to be specified there, and will still work:

127.0.0.1 www.aaa.com
127.0.0.1 www.bbb.com

From the browser, type:

http://www.aaa.com:64099
http://www.bbb.com:[port num]

The above assumes your sites are bound to specific host names (www.aaa.com, etc) and port numbers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top