Wednesday, December 20, 2006

ASP.NET 2.0 mystical Ambigous match

I recently upgraded a website from asp.net 1.1 to asp.net 2.0 "web application project"

Everything worked fine except for one small page that just wouldn't run, The first line of the aspx file reported an "ambigous match" error, and when I ran the page the same error cropped up.

It turns out that the culprit was a textbox that was defined two times in the codebehind:

protected TextBox txtPostNumber
protected TextBox txtPostnumber

with the only difference being in the casing.
Althought this clearly is fishy code, the second textbox was never used, so no harm done right?
well ASP.NET 1.1 handles this like you would expect, ignoring the other textbox.
ASP.NET 2.0 on the other hand gave me the before mentioned cryptic "ambigous match" error. It turns out that ASP.NET 2.0 acts case-insensitively in this regard.

I wonder why they changed it, and why they can't give a more useful error message...