Web Development: Introduction To Localhost and IIS

What is your “localhost”?

In computer networking, localhost (meaning this computer) is the standard hostname given to the address of the loopback network interface. This mechanism is useful for developers to test their software.

The default address for localhost is 127.0.0.1.  This special IP address, also called the Loopback Address,  is always defined to mean “the current machine”. It is not the same thing as the external IP address of your web server:

Localhost is configurable in the Hosts file (typically located at C:WindowsSystem32DriversEtcHosts). Due to multiple dependencies, it is usually not recommended to reconfigure it.

Instead, you can set up alternate domains in your Hosts file. For example, you could set

192.168.1.250   my.internal.website.com
192.168.1.249   your.internal.website.net

How Does “localhost” Relate To IIS ?

Internet Information Services (IIS) – is a web server software application created by Microsoft for use with Microsoft Windows.

If IIS is expecting a connection to IP address 192.168.1.250, then a connection to 127.0.0.1 will not match.  When IIS responds to an HTTP request, it uses 3 pieces of information to figure out what web site it should use to build the response:

  1. IP address – The browser uses the name in the address bar to perform a DNS query and get the actual IP address of the host. It sends the http request to that IP address.
  2. Port – By default this is 80 for non SSL requests and 443 for SSL.
  3. Host header – Part of an http request is a host header. This host header matches the domain name of the address requested by the user, including sub-domain or host names.
When running a browser on your machine you type: http://localhost (no port number), what does IIS do?  Per previous replies the browser converts localhost to 127.0.0.1 as the IP address and constructs an HTTP request for that IP address. The host header will be localhost.  In this scenario IIS will see that both Website1 and Website2 do not have matching ip addresses and so the default site will be used to process the request.
If you wish to have Website1 or Website2  respond to the request, disable the default site and change the IP address setting to for either Website1 or Website2. 

Intro to XML and Serialization

XML (Extensible Markup Language) is a set of rules for encoding documents sent across the internet. In simpler terms, I tend to view XML as more of a format for passing data. Let’s say you were online shopping for a calculator. The website would collect your data. For example,

Name: Master Chief
Address: 50 Forerunner Lane 98356
Item: Calculator
Price 76.98

The data above is easy for you to read if you are human, speak English, and live in America; however, if you are in France then it would need to look different for you to understand. That is one reason we have internet standards, formats, languages, etc. — we want computers “anywhere to be able to read your data and translate it to human verbatum.

If we were to translate your data into read-able XML, then it would first look something like this:

<name>Master Chief</name>
<address>50 Forerunner Lane 98356</address>
<item>Calculator</item>
<price>76.98</price>

Now, for the complicated part — serializing and de-serializing the data. Once your computer is ready to actually send the data to it’s destination, it must be serialized. Serialization is the process of converting the data into a format that can be easily sent across the internet. My definition of serialization is the breaking up of data into small parts so that it can be sent more quickly and efficiently. Once the data reaches it recipient, then it must be deserialized back into the format above.

The data above may seem pretty simple to send so why bother with serialization? Most data is not so simple. What if you want to send a whole book or an entire database? It could take forever! Also, serialization can implement encryption of your private data so that it is more secure and not easily seen by anyone else — handy for credit card information !

And that’s XML and Serialization simplified.