Logo HeaderGraphic
"... A Yankee in the Land of The Long White Cloud, Aotearoa ..."

Setting up a www.rincon.local domain in IIS for realistic dev and demos. 

Yesterday I was at a Dot Net Users Group developers talk (just watching this time) when I saw the presenter use a “more realistic” url for showing off his demo, something like “www.confidentialclassified.local”.  And I just liked the look of that.  I’ve seen it before, but never thought much about it, but I realised that from a demo standpoint, and also from a development standpoint, this was a much better approach then localhost/myWebSite/default.htm, etc.

It would allow me to more logically divide up my web projects and isolate them from each other as I was developing on my local machine (so I don’t pollute my normal localhost with transitory projects).  So I decided that this would be a good way to proceed.  Now figuring out how to set that up so it works in IIS7 on Windows 7 took a bit of doing, and in the spirit of giving back here are the steps I took to achieve that goal.

Here is the scenario:  I want to create a local “domain” called www.rincon.local for usage in development and testing.  I want this “domain” to be on my local machine, hosted from within IIS, but separate from my wwwroot localhost standard IIS7 web site.  Next I want to have my Visual Studio 2008 web service project to hosted in IIS 7 and run from this domain as www.rincon.local/<WebSite>.

We start with creating a directory to host this new domain in my inetpub directory (you can put it any place you like, but I decide to keep it located next to the standard localhost root folder)

image

Next, let’s see what we get if we surf to the base directory of localhost

localhost splash screen

We want our site when it is finally running to look like this, so let’s just copy the base files from wwwroot to our new rincon.local folder

image

image

And then so we “know” we are looking at our new site, let’s modify iistart.htm and add Rincon.Local to the file.

image

Now open IIS7, select the Sites node and click on the Add Web Site… under the actions menu

image

Name the site, select the path to the newly created directory, let’s leave the IP address as All Unassigned, but put in a port of 82 (you can use any port you like), and let’s leave the host name blank.

image

Now in IIS right mouse click on the newly created website and select to browse it

image

OK, that works

image

However if we try our www.rincon.local, it won’t work.  For that we need to go edit our local hosts file.

Open notepad but make sure to run it …As Administrator in Vista / Win 7, otherwise it won’t allow you to save your changes.  (now for the record I NEVER use notepad anymore, I only use Programmer’s Notepad, because, well, just try it for a while, and you will see why).

Navigate to c:\windows\system32\drivers\etc and open the hosts file.

image image

Now add the following to the file

127.0.0.2       	www.rincon.local

image

Save your work and close it out.

Now going back to IIS select the Rincon.Local website and right mouse on it and select to edit bindings

image

Put in 127.0.0.2, and leave in port 80. and click OK

image

Now try www.rincon.local.

image

OK, great so that’s working, on to the next part, getting our web service project to run from here.

We are going to attempt to create virtual directory from within Visual Studio, so open your web project and select the project properties.

image

OK, now select to use the Local IIS Web, and let’s set the project URL to http://www.rincon.local/RinconDeiClientWebService and click the Create Virtual Directory button (and it won’t work).

As predicted it didn’t work… we get the following error.

unable to create the virtual directory. could not find the server '<%1>' on the local machine. creating a virtual directory is only supported on the local iis server

unable to create the virtual directory. could not find the server '<%1>' on the local machine. creating a virtual directory is only supported on the local iis server

Well drat!  Now this is why we used the extra bindings for the web site, on port 82 for the local host, change the project Url: to http://localhost:82/RinconDeiClientWebService and try again.

image

Save your project now, then select one of your pages in your project, set it as the start page, and run the project

image

Well it’s working but not where we want it to. 

image

Let’s try substituting the www.rincon.local for the localhost:82 and see if it still works.

image

It does, So now you can use that url for development and testing purposes.

 
Posted on 29-May-09 by Matthew C. Hintzen
Bookmark this post with:        
Tags: