Getting Fusebox 3 to work with IIS6 Virtual Directories

Published: {ts '2011-03-27 00:00:00'}
Author: Steven Neiland
Site Url: http://www.neiland.net/article/getting-fusebox-3-to-work-with-iis6-virtual-directories/

Recently I was working on a set of sites that utilises a central cms which displays a different skin based on which domain it is being utilised in. The core files were replicated for each site domain which made maintenance a pain.

To cut down on maintenance I decided to use virtual directories to centralise the core code files into one set of directories (instead of a set per domain). All was going well with centralising the components, assets etc when I ran into a problem with the framework.

The Problem

The application is based on the now old (but still usefull) Fusebox 3 framework. When I changed a site to point a virtual directory to the central corefiles I started to get coldfusion "File Does Not Exist" errors for fbx_settings.cfm.

The Solution

After a long time googling and scratching my head, I was able to determine that the problem was NOT a permission error as many people suggested, but was actually a path issue. The solution was to edit the fusebox core file and add a leading "/" before the template include calls for fbx_settings.cfm and fbx_switch.cfm.

To do this open up fbx_fusebox30_CF50.cfm and locate sections 9 and 10. Look for the cfincludes for the fbx_settings.cfm and fbx_switch.cfm and add the trailing slashes. Below is a snippet taken from the file showing the fix. Skip down to the comments marked "SNEILAND"

Warning: This method assumes your application is in the webroot and not a subdirectory. If your app is in a site subdirectory you may have to add your subdirectory to the include path.

FB_.fullPath=ListRest(fusebox.Circuits[fusebox.TargetCircuit], "/"); //make a variable to hold the full path down to the target, excluding the root FB_.Corepath=""; //initialize fusebox.thisCircuit=fusebox.HomeCircuit; //current circuit, set to root now FB_.Corepath=ListAppend(FB_.Corepath, aPath, "/"); //add the current circuit with / as delim fusebox.IsHomeCircuit=FALSE; //fbx_settings.cfm files included in this loop are not the home circuit because the home circuit's fbx_Settings is needed much earlier in the process fusebox.currentPath=FB_.Corepath & "/"; fusebox.rootPath=repeatString("../", ListLen(fusebox.currentPath, '/')); fusebox.thisCircuit=fusebox.TargetCircuit; fusebox.IsTargetCircuit= TRUE; FB_.fuseboxpath=FB_.fullpath; //make directory path to the target circuit if (Len(FB_.fuseboxpath)){ //if the target circuit is NOT the root circuit FB_.fuseboxpath=FB_.fuseboxpath & "/"; fusebox.IsHomeCircuit = FALSE;} else fusebox.IsHomeCircuit = TRUE; fusebox.currentPath=fb_.fuseboxpath; fusebox.rootPath=repeatString("../", ListLen(fb_.fuseboxpath, '/')); I could not find #FB_.fuseboxpath#fbx_Switch.cfm (or one of its components such as an included fuse) in the "#fusebox.circuit#" circuit. If you think this error is incorrect, turn off the Fusebox suppress error messages flag by setting fusebox.SuppressErrors to FALSE, and you will receive ColdFusion's "normal" error output, which could be generated by a file included from fbx_switch.cfm.

So there you have it. I hope this helps anyone who encounters the same issue.