08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 10 ■ .<strong>NET</strong> 3.0: PROGRAMMING WITH CARDSPACE 243<br />

Step 3: Editing the hosts File<br />

The next step in the setup script is to edit your hosts file. Internet Explorer matches the<br />

domain name in the browser address bar to that in your certificate. If they don’t match,<br />

you get the errors in Figures 10-9 <strong>and</strong> 10-10. When you are setting up a development<br />

environment, you will of course be hosting the applications on localhost, which doesn’t<br />

match the certificates—but Windows provides a methodology to allow you to map IP<br />

addresses to domain names (taking a bypass around the DNS): the hosts file.<br />

This file, found in Windows\System32\drivers\etc, is just called hosts (no extension).<br />

You can open it in Notepad to inspect it. Its structure is very simple: an IP address, followed<br />

by at least one space, followed by the domain name, <strong>and</strong> an optional comment<br />

denoted by a #.<br />

The default hosts settings will likely look like this:<br />

127.0.0.1 localhost<br />

::1 localhost<br />

The samples installer adds the adatum.com, contoso.com, fabrikam.com, <strong>and</strong><br />

woodgrovebank.com sites to hosts, mapping them to 127.0.0.1 (your machine) also.<br />

When the script is done, your hosts file will likely look like this:<br />

127.0.0.1 localhost<br />

::1 localhost<br />

127.0.0.1 www.adatum.com<br />

127.0.0.1 adatum.com<br />

127.0.0.1 www.contoso.com<br />

127.0.0.1 contoso.com<br />

127.0.0.1 www.fabrikam.com<br />

127.0.0.1 fabrikam.com<br />

127.0.0.1 www.woodgrovebank.com<br />

127.0.0.1 woodgrovebank.com<br />

Now, whenever the browser is instructed to go to www.fabrikam.com, it will bypass the<br />

DNS <strong>and</strong> consider 127.0.0.1 to be the server for this domain. Now the browser will match<br />

the domain name on the URL with that on the certificate, <strong>and</strong> you’ll be able to access the<br />

site securely.<br />

As the hosts file can be used to bypass the DNS <strong>and</strong> potentially fool users into<br />

thinking they are on one site when they are on another, it is protected by Windows <strong>and</strong><br />

requires administrative access for it to be edited. However, you should check your hosts<br />

file regularly to make sure that it hasn’t been hijacked.<br />

Now that everything is in place, the final step is to install the samples themselves.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!