We saw some very strange behaviour the other day when testing an ASP.NET Web Service under mod_mono and Apache.
The application we were testing stores some configuration information in a file that’s in the root application directory. As part of the testing we wanted to setup two instances of the application with different configurations, so we copied the contents of the directory from /srv/www/htdocs/ShoutAlarmService to /srv/www/htdocs/ShoutAlarmService2 but changed the contents of the configuration file in the copy. We’re using AutoHosting on the server so the application was automatically available at the appropriate URLs: http://localhost/ShoutAlarmService/Service1.asmx and http://localhost/ShoutAlarmService2/Service1.asmx.
The strange thing was that when we went to /ShoutAlarmService2/ it was actually using the ShoutAlarmService configuration file. Further investigation seemed to show that mono was actually serving the files in the ShoutAlarmService directory rather than the copy- we renamed one of the files in the copy, but it was still found ok! We also created an HTMLPage1.aspx file in each directory, but had them printing out different messages. Regardless of the URL you went to you got the same result. However, if you did the same thing with a .htm file then you got the different files. This suggested something wrong with Mono rather than some strange Apache configuration. In the end to get it working we just renamed the copy to BlahAlarmService.
I wanted a bit of a better explanation though, so today I did some more experimentation and found that if you just copy the directories as described above you get the problem. However, if you copy the directory and then restart apache a couple of times it all works correctly. Copying to a directory called BlahAlarmService seems to work without any issues.
My guess is that there’s a funny in the AutoHosting implementation and the way it maps virtual and physical application directories. But working out the exact problem isn’t my top priority at the moment!