Kevin Grohoske

Vice President of Software Engineering / Senior Software Engineer 
MCPD-WEB, MCPD-WIN, MCSD

A long time ago before the world of Visual Studio’s Integrated Web Server and .NET you had to test web sites a bit more “manually”. Here is one trick that is a somewhat lost art.

If you want to test your web application and/or web service (very handy trick for web services)  for some reason you need it to be at a specific URL, such as http://www.testingURL.com. You will need to assign a separate IP address for your web site/webservice.

On windows servers and desktops, you can modify the “hosts” file (note there is no file extension). If you have not modified this file it should look like the following:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost

To add a new entry simply type the ip address of the actual location of the test web site/web service you are working with (ex.  222.22.22.222). And then type the “fake” name of the URL (ex. testingURL.com)

With the above information your entry into the “hosts”:

222.22.22.222    testingURL.com

Once you save this file all requests for testingURL.com will now go to the ip address 222.22.22.222.

The beauty of this solution is that you can bind a WS call to your production web service while developing and all requests get routed to your test web service! Once in production, all the calls will be routed to your production web server.

On Windows 2003 and XP the “hosts” file is located at -  C:\windows\system32\drivers\etc

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

Add comment


(Will show your Gravatar icon)
  Country flag

Click to change captcha
biuquote
  • Comment
  • Preview
Loading