I was trying to put together a prototype for a potential client but kept on getting a ‘Sys is undefined’ AJAX error when I tried to run it on my host Blacknight.ie, however when I ran it on another host - discountasp.net everything worked fine. It also worked fine on my local development machine which consists of Visual Web Developer 2008 SP1 and .Net 3.5 SP1.
There’s an absolute tonne of blog posts and forum threads on this topic but I couldn’t find an exact fix. Things like modifying the web.config are most often mentioned but that ‘fix’ usually relates to environments targeting .Net 2.0 (before AJAX was included a part of the framework core).
One blog post that did point me in the right direction was:
2009-03-02 08:27:54 GET /ScriptResource.axd 126.96.36.199 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+6.0;+en-GB;+rv:188.8.131.52)+Gecko/2009011913+Firefox/3.0.6+(.NET+CLR+3.5.30729) http://d1004190.blacknight.com/davetest.com/ajaxtest d1004190.blacknight.com 404 0 1741
The reason for this can apparently be a number of things including bad web.config configuration, bad IIS configuration and incorrect assemblies (mismatch between expected versions & actual versions) in the GAC. I’m pretty sure it’s a blacknight configuration issue though due to the fact it worked on my local machine and on discountasp.net. I’ve sent Blacknight the above link anyhow so watch this space.
What is the Sys is undefined workaround then?
However the version of the library available from the downloads page mentioned above is 3.5.30729.1. I renamed the version on the host to 3.5.21022.8 (better to download the right library of course), refreshed and it worked perfectly from then on. Interesting the src tag outputted from my local machine correctly referenced library version 3.5.30729.1.
Why does the framework on blacknight look for version 3.5.21022.8 but discountasp.net and my local environment look for 3.5.30729.1?. I’m not 100% certain but machines with 3.5 sp1 (discountasp.net & local machine) must be configured to ‘look’ for an AJAX library of a particular version, while machines of 2.0 or 3.5 will look for other versions. This means in theory a mismatch between what version of the AJAX library (well what version of the containing assembly - ‘System.Web.Extensions’ to be more correct) the framework expects and what version it finds (or doesn’t find for that matter).
To check if there’s a mismatch you could set the scriptpath property of the scriptmanager to some abitary value, upload, check the src statement which will look similar to the one above to see the expected version of the System.Web.Extensions assembly you need and then you could use reflection to check the actual version you have… of course I’m not certain on any of this mismatch business, casual theory only.