Remap IIS Home Directory From Visual Studio

23 Apr 2009 In: development

Many web developers are still using Windows XP which means they are limited to a single website instance under IIS.  If you’re like me you probably have a /dev folder with a child folder for each project website.  When you switch focus to another project you typically fire up IIS Manager, open the properties sheet for your default website, switch to the home directory tab, type in the new path and then hit the Ok button.  Sure it doesn’t take too long but what if you could do all of that from a single click within Visual Studio?

The following is a short batch file that will accomplish just that.  Once the batch file is added as an external tool switching websites is a click away.

   1:  @echo off
   2:  SET str=%1
   3:  SET str=%str:~1,-3%
   4:  cscript.exe "c:\Inetpub\AdminScripts\adsutil.vbs" SET /W3SVC/1/ROOT/Path %str%
   5:  rmdir /s /q "%userprofile%\VSWebCache"
   6:  pause

  1. Save the batch file in a sensible location.  I use C:\Program Files\tforster\utils\setIISPath.bat. 
  2. Fire up Visual Studio (I’m using VS2008 but this should work for VS2005) and choose Tools | External Tools…
  3. Click the Add button.
  4. Give the new entry a title.  Mine says “Set IIS Home”
  5. In the Command: field enter the full path to the newly created batch file.
  6. Click the arrow to the right of the Arguments: field and choose $(ProjectDir)
  7. Click OK.

Open up a web project then choose Set IIS Home (or whatever you named your entry) from the Tools menu.  Open your web browser and browse to http://localhost.  You should now see your default page (assuming that you have created a default page, otherwise try http://localhost/your_special_page).

If this doesn’t work for your consider the following assumptions.  You may need to tweak things if your development environment differs from mine.

  • My setup assumes the default http port of 80
  • My web root source code is in the root of the Visual Studio project directory
  • IIS admin scripts are installed to the default path c:\Inetpub\AdminScripts\adsutil.vbs.

Tip: Add The Same Behaviour As A Windows Explorer Right-Click

Sometimes it’s more convenient to switch default home directories from within Windows Explorer.  If you’re comfortable editing registry entries then try this:

  1. Open Regedit
  2. Navigate to HKEY_CLASSES_ROOT\Folder\shell\
  3. Right-click on shell and choose New Key
  4. Name the key “Set IIS Home” or whatever you want to see in your right-click menu
  5. Open the new key and double-click the (Default) String Value to edit it.
  6. Enter the full path to your batch file plus a space and “%L”.  Mine entry looks like C:\Program Files\tforster\utils\setIISPath.bat “%L”
  7. Click OK

Now browse to your development folder, right click a child folder containing a web project and choose Set IIS Home

Tip: Run Multiple IIS Compatible Web Servers On Windows XP

Windows XP is a great client operating system and a perfect Windows development platform except that Microsoft chose to limit the number of websites to 1.  This was presumably to stop people from trying to use XP as a production server platform and thus denying Microsoft potential Windows Server licensing revenue.  Microsoft reversed this behavhiour with the release of Vista but that doesn’t help those of us that are still bound to XP at the office.  This becomes particularly problematic when you are working with web services and need to connect your debugger to the consumer and service applications.

Anyone familiar with Visual Studio is aware of the built-in development web server.  Typically hitting F5 invokes the server on a seemingly random http port.  You can use the development server in conjunction with an IIS hosted site to build a development web services infrastructure.  But it’s annoying having to repeatedly edit web.config files to account for the different ports, not to mention that F5 starts the site in a virtual directory which is almost always different than production.

Did you know that you can invoke the development server manually?  And if you can invoke it manually you can configure an external tool to do so with a single click?

I have a number of webservices that I routinely need to run on my development box.  Each one has a pre-assigned port number and is root mapped, rather than hanging off virtual child directory.  My Tools menu contains entries such as:

  • Thumbnail Service (8001)
  • iPhone Service (8002)
  • xyz Service (800n)

I can easily start one or more of these services, each running in a separate instance of the development web server and each can be connected to with the Visual Studio debugger.  To configure your first service open Tools | External Tools…

  1. Click the Add button.
  2. Give the new service a title.  I usually put the port I’m going to use in brackets so it’s easy to remember what I’m using.
  3. In the Command: field enter C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE.  Check your system if you’ve installed Visual Studio in a location other than the default.
  4. Enter /port:<your_preferred_port_number> /path:"<path_to_your_project>" /vpath:"/" in the Arguments: field.
  5. Click OK.

If you choose your new service from the Tools menu you should see the usual web developer icon appear in your task tray.  Depending on how you have implemented your project you should be able to navigate to http://localhost:<your_port_preferred_port_number> and see your default page or service endpoint.

To connect to the running instance with the Visual Studio debugger goto Tools | Attach to Process… (or Ctrl+Alt+P), make sure the Transport is set to Default, scroll through the list of available processes until you see WebDev.WebServer.EXE.  Double-click it attach.  Note, if you are running multiple servers this way each will show up with the WebDev.WebServer.EXE process name.  Check the title column to determine which one want to connect to.

I woke up this morning realizing that I didn’t have plans to do anything in particular. 

Hello lazy Saturday.  What shall I make for brunch?

Espresso to start.  That means grinding up a blend of organic and fair trade beans that I buy from Moon Bean in the market.  It’s always great kick starting a weekend with a rich, high octane cup of rocket fuel.

With my espresso in hand I par boiled several potatoes that had been sliced into 1/2 cm rounds.  Once drained they were tossed in some olive oil, rosemary, fresh ground sea salt and pepper corns then transferred to the oven at about 400 degrees.  I knew the potatoes would take at least 45 minutes to cook which allowed me to enjoy the remainder of my espresso as I got caught up feeds and tweets since I went to bed last night.

With the potatoes crisping up nicely I started grilling up a couple of tomato steaks and got the water simmering for some poached eggs.  Lastly I toasted up some ciabatta just as everything else simultaneously reached it’s apogee of cooked perfection.

It was an epic brunch better than any I’ve ever had at a restaurant.  There was a dozen or so rosemary potato chips left over which will be perfect to nibble on the rest of the afternoon while I work on a new jQuery project.

One of my colleagues is involved with an application that is required to display thumbnails that have been created and uploaded by our users.  The thumbnails come in many sizes and orientations yet still need to be displayed in a consistent fashion.  I quickly whipped up a jQuery plugin called frameIt to take care of this.  frameIt takes the supplied list of images and applies padding on a case by case basis to achieve the effect.  You can see how the following two images have been centered and framed inside a consistently sized red box.

frameIt’s default settings can be overridden to allow for full control of sizing, whitespace and border styling.  An example of frameIt in use is:

   1:  $("img").frameIt({
   2:     width: 200,
   3:     height: 100,
   4:     borderColor: "#FF0000",
   5:     padding: 10,
   6:     borderStyle: "solid",
   7:     borderWidth: 1
   8:  });

jquery.frameIt.js (1.55 kb), jquery.frameIt.min.js (983.00 bytes)

More Secrets Of Javascript Libraries

21 Mar 2009 In: development

Last week’s SXSW conference in Austin, TX had a panel session that was hosted by authors of four of the leading JavaScript libraries.  Each speaker was given ten minutes plus Q&A to present a topic of particular interest to themselves.  They included:

  1. Nate Koechley of YUI speaking about network performance and file loading.
  2. Andrew Dupont from Prototype discussing the abstraction provided by using frameworks.
  3. Dojo’s Becky Gibson quickly introducing the upcoming ARIA specification.
  4. John Resig, creator of the awesome jQuery library talking about performance analysis and testing techniques.

Some of the slide highlights for me where:

  • Slide 44: The introduction of YUI’s Loader and Get utilities plus the “seed”.  Outside of the YUI dependency of course this is supposedly a library agnostic way of combining multiple script references on a page to a single reference.  A single reference is preferable since it requires far fewer HTTP GET requests.  The YUI utilities also include JIT loading of dependent scripts.  This means you should be able to reference that large image manipulation script on your photo page, but not actually download it unless the user decides to edit a picture.
  • Slide 118: John Resig has written a jQuery plugin that can be used to do deep-profiling of the JavaScript stack
  • Slide 129: I had no idea there was a unit testing plugin for FireBug
  • Slide 139: This slide shows a graph of the Cost/Benefit ratio of developing for IE6, IE7, FF3, Safari 3 and Opera 9.5.  Guess which one had the highest cost to benefit?  IE6 was the worst and FF3 the best.
  • Slide 140: A screenshot of the Yahoo Graded Browser Support Chart.  Although I’ve seen this chart before it was particularly pertinent for me since I’m dealing with some serious issues involving support for Safari 2.  Interestingly Safari 2 doesn’t even show up on Yahoo’s chart.  It also makes me think about Internet Explorer 6.  Many web developers are very quick to jump on the anti-IE6 bandwagon (I’m guilty too) but the development community might be far better off adopting universal support for a graded browser definition.  Because as much as IE6 is a pain in the ass to deal with, Safari 2 is an impossible nightmare!
  • Slide 142: The jQuery Browser Support Grid for jQuery 1.3.  This was a frightening slide.  Assuming there is no typo it tells us that jQuery 1.3 does not support Safari 3!  It does support 3.2 and the pending 4.0 release.  As a result I have a task on Monday to go through the analytics for all the projects I support to see how many visitors are showing up with 3.0 browsers. 
  • Slide 147: jQuery will be debuting TestSwarm at the end of March.  It’s a distributed continuous integrated testing environment for JavaScript. 

My Twitter Mosaic

16 Mar 2009 In: socia-media

Here’s yet another Twitter mashup.  It doesn’t offer much of value other than a cool visualization of your friends or followers.  Here’s my followers as of today.

Unfortunately it’s a statically generated list from http://sxoop.com/twitter/mosaic.pl.  It would be very easy to do the same thing using a bit of javascript and a JSON-P call to the Twitter API.  Hmm… It would look cool with a jQuery coverflow plugin.

About this blog

me_blackshirt

Here you will find posts about a lot of the things I am interested in including technology, social networking, human powered outdoor sports activities, sustainable practices, food, wine, friends and family.  I’m quite active in other parts of the web and you can find those by simply googling my name or my id (tforster).  Alternatively scroll down a bit for my latest Flickr, Twitter, Facebook and FriendFeed highlights.

 

 

Flickr PhotoStream


FriendFeed

Twitter Badge

Latest Tweets

Sponsors