BlueDragon Blog
Here you'll find tips and information about making the most of BlueDragon, which offers several compelling implementation alternatives for your CFML applications. This blog was created originally by Charlie Arehart, who was New Atlanta CTO from 2003-2006.,He has since moved on to become an independent consultant but continues to answer comments raised in existing blog entries. BlueDragon continues, and you should look to the newer BlueDragon blog, from New Atlanta president, Vince Bonfanti, for more updated information.

Running multiple web sites at once on non-server editions of IIS

posted Monday, 29 August 2005

If you're using IIS on Windows XP (or Windows 2000 Professional), you may have noticed that you can't create more than one web site--unless you use one of the tools I'll describe here. (These may be old news to some, but if you've missed, it will be a delight to solve.)

Background

This limitation of one website for IIS on non-server editions of Windows is a mild annoyance for most, but if you're testing some code against multiple versions of some application server (such .NET 1.1 vs 2.0, or BlueDragon versus ColdFusion, or different editions of each), it can be quite limiting. If you want to cause a given set of pages to be handled by one of these different servers at a time for testing purposes, there's just no easy way.

For my needs, I don't mind not being able to RUN more than one at a time. I just need to be able to configure ones differently (different extension handlers/script maps) and run the sites one at a time. (Note that the problem I'm describing is different from wanting to run different web sites with different docroots at the same time, though that can be solved by one of the tools below.) The following tools each offer a different take on this problem.

IISAdmin

http://www.firstserved.net/services/iisadmin.php

The easiest solution to this challenge yet may be IISAdmin, a simple yet useful tool created a couple years ago to solve this very problem. With it, you get a small task tray bar which allows you to create new web sites (yes, even on IIS 5.1 on XP), and also permits controlling their stop/start. The created web site does appear in the IIS Manager interface (if you refresh its screen), and from there you can also start/stop the site. With it, I can create a ".net 1.1" site, a ".net 2.0 site", a "BlueDragon/.NET site", a "BlueDragon/JX site", a "CFMX 6.1 site", a "CF5 site, a "CF7 site" and so on. I can point them all at the same docroot (if that's what I want) and run any one at a time to test the code against the given server.

Again, you can have only one site running at a time. If you try to start more than one in IIS manager, you're told "the request is not supported", and if you try it using ADSUtil (see below) it says "error trying to start".  (You'll notice that the interface lets you indicate the "site id" and auto increments it, so the first site I created had an id of "2", useful with ADSUtil and other scripts.) A neat trick in the IISAdmin interface is that if you try to start a site when another is already running, it will stop the other and start the selected one.

One annoyance I have observed (on my machine, at least) is that the tool, when running, doesn't show up in the list of tasks (either in the taskbar or in the alt-tab list), which is strange. And though it says that it sits in the tasktray, I don't see it there when it's actually running. I had to minimize everything to get to it, which I really don't care for. Still, if you use it only infrequently, it's a minor quibble.

I also noticed that on installation, it didn't start automatically, and I didn't see it in the Start>Programs menu, so I was starting it from its installation directory--then I noticed it placed itself in the Start menu. YMMV.

Other Solutions

I'm sure some readers here will want to point out that there are still other ways to achieve similar solutions.

Virtual Directories

For one, you can use virtual directories to achieve this flexibility and not need to bother starting/stopping web sites. You have just the default web site, with several virtual directories (using different "alias" names you'd use to distinguish them on the URL), and each is configured to have its script mappings set to point to the different servers of interest. (I've documented how to do this more in a Sept 2003 CFDJ article). I've used the approach a lot, but some apps might not work under this setup. If they've been written to presume they will run at the root of the site, they may eventually redirect to the root if you're not paying attention. (Actually, this problem can happen even on Server editions if you're using ports to redirect, as some apps could lose reference to the port eventually). Still, it's an acceptable solution.

MultiSite

http://www.hairy-spider.com/multisite.aspx

Multisite takes a different tack. With it, you can create multiple web sites by means of an ISAPI filter and use of host headers, to direct different requests to different docroots and effect a means of running different "sites" at once. This is a better solution for those wanting to really "run" multiple sites at once on a single IIS non-server instance. I haven't tried this one, as it doesn't seem it will solve my need (I really need to configure the script maps differently, and am not even interested in varying the docroots). Still, worth your consideration.

ADSUtil and ADSI scripts

There's a whole world of powerful scripting possibilities to effect changes to IIS at the command line using scripting (see the awesome ScriptCenter to learn more.) There are tools to list, add, start, stop web sites and virtual directories. For the problem at hand, you could easily create a copy of your current web site with this command line request:

cd c:\inetpub\adminscripts\
cscript adsutil.vbs copy W3SVC/1 W3SVC/2

From there, again, you could just use the IIS Manager interface to edit this copy of the "default web site", to rename it, edit its settings, start/stop it, etc. The ADSUtil interface and scripting tools aren't as helpful for editing the extension mappings (what they refer to as the ScriptMap property of a web site), but it's easy enough to edit in the IIS manager interface. Again, this, like IISAdmin, at least get around the IIS manager limitation that would otherwise restrict your even creating a new web site.

.NET 2.0 IIS Manager Interface

Someone may also want to point out that if all one wants to do is change a site between running on .NET 2.0 and 1.1, it's possible now to do that from within the IIS Manager interface, once you install .NET 2.0. When looking at a site (or virtual directory's) properties, there is a new "ASP.NET" tab which has an option to switch the version for that site/VD between 1.1 and 2.0. This basically just changes all the script maps that have references to the ASPNET_ISAPI.dll to switch between the 1.1 and 2.0 version.  (As an aside, when you change it to 2.0, this also exposes a nifty interface there for editing the site/VD properties as an alternative to editing the web.config.) 

New non-IIS based web server in Visual Studio .NET 2005

Someone may also want to point out that you don't even NEED to use IIS if you don't really want to, if you have Visual Studio .NET 2005 (and any of its many variants). It now has a model for deploying your app with a built-in web server (do a search on Cassini to learn still more, which you can even use before getting VS2k5), so you don't even need to rely on IIS if you don't want to. Again, for the development purposes I'm describing, it's an option to consider.

Install Win2k3 Server

It's worth suggesting that rather than hassle with these work-arounds, you could just go ahead and install Windows 2003 Server (or even Win2k Server), if you have or want to procure a license. You are then permitted to have multiple web sites. If you move up to Win2k3, just beware of differences in configuration, improved security, software compatibility, possible driver issues if used on a laptop, etc.

VPC

Someone will want to point out that rather than switch your entire server, you could also just create a new virtual server, using MS Virtual PC (or VMWare). Yep. Again, just subject to licensing (and resource availability on your box).

Port Issues on Multiple Sites on Server Editions

As for running multiple sites on the Server editions, here's something to think about. If you try to use different ports to distinguish running on the different sites, just keep in mind that as some apps don't like running in a virtual directory (as described above), some don't like running at a port other than 80 (they may start out ok, but soon get redirected to a URL with no port reference, thus defaulting to 80). This is all about how you or the author wrote the code, and whether it's sensitive to keeping track of the port being used when doing redirections with full path URLs or otherwise setting the URL.

In such a case, you may be better off using host headers to distinguish sites. But if you're not comfortable with setting that up (may require changes in the "hosts" file on your development workstation, as discussed in the Multisite page above), just keep in mind that another solution (on a dev server) is to use multiple web sites--all using port 80 to keep things simple--but running only one at a time, to permit testing against different servers. Remember, this is the goal I was trying to achieve here.

Apache

Finally, someone will want to point out that you could "just use apache". Yes, I suppose for some needs that's a solution, but not so good when integrating with .NET. I don't want to open that can of worms. Just know it may be another option for you.

Other resources on this challenge:

My thanks to Mike Gardiner who pointed me to IISAdmin today on the BlueDragon Interest list, which started me on creating this blog entry. Other sites that discuss these solutions are:

http://blog.crowe.co.nz/archive/2005/08/08/179.aspx

http://discuss.joelonsoftware.com/default.asp?joel.3.72767.16

http://www.codeproject.com/csharp/IIsAdminNet.asp

http://ray.camdenfamily.com/index.cfm?mode=entry&entry=153FE53E-F5A0-F2C5-D9B1FE71913F792B




1. Charlie Arehart left...
Monday, 29 August 2005 3:13 pm

If you're finding the multisite link broken, the problem is on their site (not with my link). But you can find it in the good ol' Google Cache, at:

http://64.233.161.104/search?so urceid=navclient-menuext&q=cache:http%3A//www.hairy-spider.com/multisite.as px

Yes. Even the link to the download works fine from there.