For a long time, whenever I've been developing a site, I would always set it up in IIS with a custom host header and modify my windows hosts file to wire it all up. I know a lot of developers don't go to this extent, instead plumping to only run it via Visual Studio and Cassini. I've never been a fan of this way of working, mainly because I like to have access to my sites at all times, without having to launch Visual Studio (especially if I'm developing an Umbraco site, and all I need to do is update some CSS or something which I can do easily and quickly via the UI). The downside to setting sites up in IIS though, is that it does add extra steps to the beginning of a project, which can get tedious.
After reading a blog post by Aaron Powell, it got me thinking though. Why not use IIS Express to dynamically serve a directory as and when I need it? So with that, I knocked together a simple .vbs script you can drop in your "Send To" context menu folder (C:\Users\[YOUR_USERNAME]\AppData\Roaming\Microsoft\Windows\SendTo\), which will launch an IIS Express instance with it's path attribute set to the "Sent" folders path, and it's port attribute set to a random number between 1024 and 9999. The script will also then launch the generated URL in your default web browser. When you want to shutdown the web server, you can stop it using the IIS Express System Tray context menu.
If you'd like to try this yourself, just drop the following into a .vbs file and save it to your "Send To" folder.
' Init randomization Randomize ' Set random port number Dim port port = Int(Rnd() * 8974) + 1025 ' Launch IIS Express / Browser Set WshShell = CreateObject("WScript.Shell") WshShell.Run """%programfiles%\iis express\iisexpress"" /path:""" & WScript.Arguments.Item(0) & """ /port:" & CStr(port) & " /systray:true", 0, False WshShell.Run "http://localhost:" & CStr(port), 9, False Set WshShell = Nothing
UPDATE – March 15, 2011 12:25
As highlighted by Lee Kelleher in the comments, if you are using a 64bit OS, then please make sure to change %programfiles% to %programfiles(x86)%