Routes sometimes don't match

I’ve noticed some odd behavior with routes where occasionally a request that should match one of my defined routes doesn’t “match” the route and the request gets treated as if it didn’t contain any route information in the URL. For example a request for http://www.mydomain.com/accounts/123 is treated as if it was http://www.mydomain.com/ and the application homepage is displayed. The ColdBox debugging panel shows:

Current Route: N/A
Routed URL: N/A

If I refresh the browser then the route matches correctly and displays the correct page. This has happened with multiple routes on both a development server and a testing/staging server. The first couple of times I thought it was just a fluke, but it’s happened enough times that it’s starting to cause me a little concern. (It still doesn’t happen very often, probably less than 10 times during the last month or so of development.) I haven’t been able to reproduce the issue on demand. Also, I’m not certain, but I think it seems to happen more frequently right after I reinitialize the application.

Any ideas what’s going on here or what might be causing this?

P.S. I’m running ColdBox 3.0 on Windows Server with IIS.

Not on top of my head. Is iis doing your rewrites? Might want to enable logging on it and see whyit does that.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

IIS does have a rewrite plugin installed, but I’m just using the default .htaccess that ships with ColdBox. If the problem was with the IIS rewrite then I would expect a 404 error as my SES URL doesn’t match a real file on the server. But the request is being sent to the application because the homepage is being displayed, so it would seem that the IIS rewrite is working correctly.

I’ll set up some logging on the CGI.path_info variable to make sure that’s being set correctly. That’s what ColdBox uses to get the route info from the URL, right?

yes

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

To confirm, did you import the .htaccess file into IIS so it could generate the webconfig.xml?

No, I'm not sure what you mean by "import". The .htaccess is just in the application's root folder. The IIS rewrite plugin we're using works basically the same as it does in Apache--it checks the folder to see if a .htaccess exists and if so applies it to the request's URL.

Sounds like you are using the Helicon ISAPI Rewrite plugin. BTW this is the
extreme best plugin for ISAP Rewriting for IIS.

Do you know which routes are not matching, if it is this plugin I too use it
and don't have problems with it.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of Richard Davies
Sent: Wednesday, 6 April 2011 1:02 PM
To: coldbox@googlegroups.com
Subject: [coldbox:9213] Re: [coldbox:-1] Routes sometimes don't match

> To confirm, did you import the .htaccess file into IIS so it could
> generate the webconfig.xml? --

No, I'm not sure what you mean by "import". The .htaccess is just in the
application's root folder. The IIS rewrite plugin we're using works

basically the

same as it does in Apache--it checks the folder to see if a .htaccess

exists and

Yes, that's the one we're using. I'll have to pay attention and see which route doesn't match if it happens again, but I'm pretty sure it's happened to more than one of my routes. I'd be really surprised if it's the Rewrite plugin that's at fault. We've been using it for a while now with other non-ColdBox apps and haven't had any similar problems. I've got a feeling it's something with ColdBox, but don't know for sure yet.

If you are using a recent ColdBox 3.0 (or the final release) you can implement logging in your Routes.cfm file using the function PathInfoProvider(Event) function. This method returns the CGI.PATH_INFO (if the method is defined) to the SES interceptor. Adding the following will make things very easy to track:

function PathInfoProvider(Event){

local.path = cgi.path_info;
// – log something here
return local.path;
}