Pages

Thursday, September 11, 2008

Case sensitivity

Everybody knows that net is case insensitive - no matter whether you go to http://GOOGLE.com or http://GoOgLe.CoM - you still gonna end up on the same web site and see the same page, right? I thought so too. Until yesterday.

Currently I'm working on a web service (C#/.Net 1.1/IIS6.0). It's already deployed and working at one location and we are getting ready to roll it out at the second one. So on my QA server I have two applications: /Service and /Service.EXT (note the capitalization), pointing to the two different databases (same codebase mind you). Couple days ago on the call our front-end developer asked me what's the URL for the service for the second location and being blissfully unaware I told him "just add .EXT to the application name". As you may know it's tad bit difficult to capitalize over the phone (unless yelling) so he did as I said: http://website/Service.ext/Service.asmx. Do you see a problem? Neither did he or I (yet).


Yesterday I got an email from our tester that one of the service operations fails. In the log there was an error that filewatcher threw an exception because of the non-existing directory (/level up from deployed code root/Service.ext). Well, duh - there is no such directory. Of course I don't use any file watchers either, so I had to dig deeper and found that one of our internal company shared components uses it to monitor some cache file it creates (I'm not gonna say anything abouth them writing into the application directory instead of the temp directory - that's totally different rant). The way they obtain the path is very simple: HttpContext.Request.MapPath("") - map virtual path to the physical path. This can't be a bug - someone would scream long time ago, plus the original application (Service) works like charm.

So off to do a little test I went.

When web service URL is "http://website/Service.ext/Service.asmx" - MapPath() returns "/level up from deployed code root/Service.ext"; when URL is "http://website/Service.EXT/Service.asmx" - MapPath() returns "/deployed code root" as expected.


Wow. I had to call front-end developer to ask him to change the case of the URL he's using. Just... wow...

No comments: