Tuesday, 27 October 2009

Visual Studio 2008 + IIS 7 development

At my new job part of my role is to bring most of the current website development in house for the 8 websites we currently have. Due to this I have decided to instead of just run them on the built in development web server which ships with Visual Studio and launches when you hit f5 with an address something similar to http://localhost:58697/Website1 to setup individual websites in IIS to best replicate the production environment. This is possible as IIS 7 on Windows 7 allows multiple websites on the client OS.

To do this I did the following:

1. Create a new website in iis 7 manager console; setting the host name to <identifier>.localhost

image

2. Update the hosts file to point the local loop back ip address to know about this new host name. Open the hosts file found in C:\windows\system32\drivers\etc\ and add the following line:

127.0.0.1                         website1.localhost

3. Open the Visual Studio solution (as Administrator) with the website in and navigate to the property page of the website. Navigate to Start Options > Server > Use custom server and set the Base Url to http://website1.localhost

image

4. Hit f5 in Visual Studio and run it.

I hope this helps anyone looking to do a similar thing.

Enjoy :-)

No comments: