A plea out to all those who are using ASP.NET AJAX with sites on IIS7, either under Vista or Longhorn Server:

I've been battling a strange issue with ASP.NET AJAX on IIS 7 running under Vista.  It's a site that was upgraded from RC1 to RTM, and works great under IIS 6.  Have troubleshot it enough under IIS 7 to determine that if the AppPool has the Managed Pipeline Mode set to "Integrated", it fails, and if it's set to "Classic", it works perfectly.  The error I'm getting is one that was common during the beta, the Javascript error "Sys is undefined".  This happens right after the <ScriptManager> element is parsed.

Of course I've checked all the standard things like making sure the System.Web.Extensions assembly is referenced, and adding this under httpHandlers:

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

For awhile it seemed like it may be related to forms auth restricting access to the .axd script handlers, and this solution from Emad looked promising.  But after trying all manner of <location> elements in the web.config to designate the scripts to load, and even disabling forms auth altogether, it still didn't work.

It is a site that uses master pages, so there's all the good strangeness of Intellisense while developing in VS.  You have to have the master page open in order for Intellisense to properly show ASP.NET AJAX elements in the child page.  Perhaps the classic pipeline handles these master page scenarios properly, while the integrated pipeline does not.

I'm also wondering if this could be some kind of compression issue.  I know that IE 6.1 had issues reading compressed scripts unless you applied a hotfix, and would exhibit this problem.  But this comes up with both the patched IE6 and IE7.

I guess my next step will be to meticulously compare web.configs between a fresh project and this converted one.  Then if that doensn't help it will be time to break out with Fiddler and see exactly what's going across the wire.

Troubles aside, dang, ASP.NET AJAX sure is slick when it's working!

(Edit) AHA, a solution!

Turns out in the web.config nestled under <system.webServer> / <handlers>, I was missing this entry:

<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

Y'know, there are so danged many moving parts that can get in the way of rendering the scripts from a <ScriptManager>, I think when I have a moment I'll write up an article to help folks troubleshoot all of them.


Feedback

# AJAX fun with the dreaded 'sys is undefined' error

If you have started to play with AJAX then you have most likely come across the dreaded 'sys is undefined' 4/9/2007 4:24 PM | Is This Thing On?

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

This solution does not seem to work on child sites that are accessed as modules in a framed site. Any ideas would be greatly welcomed.

Thanks 5/30/2007 1:04 AM | Ramon Tristani

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

I just downloaded AJAX 1.0 today and installed it on my web server (WS2003 all current updates).

I still get the Sys is undefined error. My web app works in Visual Studio; but does not work when called outside of Visual Studio. I have tried all the suggestions I could Google in 4 hours including the ones above.

Does anyone have AJAX 1.0 working yet?

There must be a way to get it to work! 8/1/2007 2:36 PM | Arnold

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Thanks man! I've been looking at this for a while before I came across your site. All of my AJAX was working until I switched to Vista and then all of a sudden it didn't work while I was trying to debug. I was missing the 'preCondition="integratedMode"' piece in my web.config. Put that little baby in there and voila! Everything works again!
Thanks! 8/23/2007 6:38 AM | Chris

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

I already have the above suggested line in web.config then also getting same error
11/30/2007 7:29 PM | Ramesh

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Hi,
Getting syntax error when using import System; in javascript. I want to use the System.setClipboard function. How can I resolve this issue.. Urgent help is needed..

Thanking you 12/16/2007 7:32 PM | Muthu

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

1. I've installed window 2003 SE sp1 on my server
2. downloaded AJAX 1.0 with the Toolkit
3. Uploaded it to my server,
4. Within IIS I created an application under my website
5. get the same error.

i've been searching for HOURS and almost start to cry 1/10/2008 11:45 AM | Marcel Ruiter

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

I too had the same problem.fixed it.My system date was set to past.when i changed to current date,the problem was solved. 1/16/2008 2:30 PM | anu

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

My web.config already has this, but unfortunately it still doesn't work. ANY help is appreciated. Also I'm working within a frameset. Any solutions for this scenario? 2/19/2008 7:02 AM | vkumar

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

We are using a policy manager to secure our site. When we removed the mapping, the error was gone but of course so was our security. We fought with this for days, I just noticed that the drive mapping for the Wildcard Application map was set to check if the file exists. This makes sense, because the file is on a local drive, but I suspect it's applying that check to the .axd file as well and we got the 'Sys undefined'. Now apparently all is well (hope I didn't speak too soon).

This is an II6 system, Win2K3. 3/9/2008 1:50 AM | Paul

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Thank you!
I've been having some issues, now solved with the classic mode. What's the difference between the modes?

I've also changed in web.config and will now turn back to integrated mode. 3/18/2008 5:47 AM | Stefan Bergfeldt

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

My web.config already has this, but unfortunately it still doesn't work., could u plz update me for this...?
4/23/2008 7:45 PM | Chandrashekhar

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

For what it's worth, I was pulling my hair out trying to fix the sys not defined error. It turns out the whole error was connected to a back dated system date I had. Once I corrected my system date to the correct date, everything worked fine.

Go figure, thanks ANU!!! 6/22/2008 12:24 AM | Andrew

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Thanks to Chris Riccio for this snippet whic worked for me.
http://weblogs.asp.net/chrisri/archive/2007/02/02/demystifying-sys-is-undefined.aspx

In the Web.config;
<system.web.extensions>
<scripting>
<scriptResourceHandler enableCompression="false" enableCaching="true" />
</scripting>
</system.web.extensions> 7/29/2008 5:22 PM | Rick

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Thanks for the tip. I was struggling with this one. Your suggestion got me going again. 7/31/2008 8:28 AM | Scott Marlowe

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

None of these work. Isn't anybody an authority on this subject or is everyone simply hoping it works? 8/16/2008 9:32 AM | anon

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Tried everything listed and still doesn't work. Any other solutions? 8/19/2008 8:08 AM | anon

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Here's one more data point for anyone reading this far . . .

I have been working with a Web.config file set up by a separate development team and, while they seemed to have correctly entered all of the necessary elements listed in this article, I was still getting "Sys is undefined". I noticed another element in the <system.webServer> section they had added that wasn't mentioned above:

<validation validateIntegratedModeConfiguration="false"/>

Changing that attribute to "true" finally, finally solved this problem for me. Hope that helps someone . . . 9/22/2008 8:12 AM | Pete

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Thanks for all the suggestions. None of them here helped, but the comment on this MSDN blog page worked out:

http://blogs.msdn.com/zainnab/archive/2007/04/09/ajax-fun-with-the-dreaded-sys-is-undefined-error.aspx

In particular, the problem lay in where the web.config file was placed - in a sub-directory off the website, not the main directory. Moving the web.config to the main directory of the website solved it.
11/13/2008 10:10 AM | Peter

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Wow, this one took me some time to resolve too. All the above were very informative but didn't resolve my issue. In my case I'm rather new to IIS7 and the system.webServer options. I copied some config options from a sample and that was my undoing. In the options I had the following line:

<requestLimits maxAllowedContentLength="30000000" maxUrl="250" maxQueryString="25" />

If I tried to load the ScriptResource.axd?long-param directly I got a 404, then I realized that the QueryString param was way longer than 25 characters. I changed the line to read:

<requestLimits maxAllowedContentLength="30000000" maxUrl="500" maxQueryString="200" />

Wouldn't you know it the ScriptResource.axd loads and "Sys is undefined" is gone!

Hope that helps anyone who may have a similar setting in their web.config or applicationHost.config file.

Cheers... 11/27/2008 6:02 AM | Phill

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Wow this post saved me! IIS7 is so different then IIS6 a lot of thing that were easy to do are suddendly very complicated. This post will help me make my URLRewriting work in IIS7 too! Thank you. 12/2/2008 3:34 AM | FredericM

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

thanks alot


<httpHandlers>

really works for me !! you saved my life! =D
1/16/2009 6:14 PM | lawl

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Hi,

Thanks for the article this works gr8.. but remoove NAME & PRE CONDITION. It is not supporting..

Thanks Alot 1/20/2009 4:21 PM | Snehal

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Hi,
I had this issue until I compare my code with a sample (updateprogress example) from msdn.
Actually, you have to define the <script>
element containing the Sys.WebForms.PageRequestManager.getInstance() reference AFTER the <asp:ScriptManager> element.
I lost half a day with this "obvious" error ;-(
Hope it helps.
2/2/2009 11:28 PM | wokamoka

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Woww...the solution worked great for me too...placing the Sys.WebForms.PageRequestManager.getInstance() reference AFTER the <asp:ScriptManager>. I tried all the solutions mentioned above, did changes to web.config file, but none of them worked. Simply placing the code after ScriptManager works great...!! 2/26/2009 11:52 AM | Vidhu Jain

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Ok, this is weird - I tried ALL of the above, but ultimately what fixed the issue was simply called ScriptResource.axd itself.

Once I did that, it threw an error (Throw404) - but ever since it's been working fine. Dunno - might help someone! 2/28/2009 9:30 AM | Tony B

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

thanks!

this worked great. this was indeed tough to track down. 3/10/2009 5:34 AM | brian

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Well done! It solved my problem! Keep going 3/30/2009 11:49 PM | Joao Machado

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

I tried everything for 'Sys is undefined' problem for my website. Nothing worked until I changed one setting in IIS 6.
Right click on Application => Properties => Directory Tab => Configuration Button => Under Wildcard Application Maps choose one or all (i only had one) => Edit => uncheck the 'Verify if file exists' checkbox (or delete if not needed). Page is working as expected now. 4/30/2009 8:42 AM | Steve

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Thanks to Chris Riccio! I have been chasing this for DAYS!!!!

YOU ROCK! 5/26/2009 6:32 AM | Bob Taylor

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

I get the same thing as michael please help.. 11/8/2009 11:25 PM | DDos Protection

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Worked for me , Thanks ! 12/20/2009 10:55 PM | Tamer

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Considerably, the article is in reality the sweetest on this laudable subject. I fit in with your conclusions and will eagerly look forward to your incoming updates. Just saying thankx will not just be enough, for the superb clarity in your writing. I will immediately grab your feeds to stay informed of any updates. Gratifying work and much success in your business dealings! Greets, Vrisa... 3/6/2010 6:59 PM | puzzle games download

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

I also struggled a bit with this undefined Sys, and found that adding the ScriptResource to the handlers under system.webserver was the solution. I also found that the order in which to place these handlers really matters.

When adding it to the end of the list of handlers, it didn't work. When I added it directly below the handler AssemblyResourceLoader-Integrated, it worked like a charm! :) 3/17/2010 8:22 AM | Kjetil Myhre

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Yes for IIS 7, now we have to take care of system.webServer section of web.config. Registering httpHandler in system.web is not enough now :( 5/10/2010 5:32 AM | Haris

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

I recently switched servers and this screwed up my Ajax pretty much completely disabling my site. Thank you very much for the fix... I was searching all day with no success. :) 7/17/2010 12:37 AM | THANK YOU SOOO MUCH

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Please please please do check that the Server has the correct time and date set...

After about wasting 6 hours, i read it somewhere...

The date and time for the server must be updated to work correctly...

otherwise you will get 'Sys' is undefined error. 7/25/2010 12:23 AM | junk yards

# re: Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7

Thank you guys!!
This was helpful and my problem was resolved using IIS7.

Appreciate 9/1/2010 8:40 AM | rabih riachi

Post a comment





 

 

News


Welcome to my blog.
Here's what we've got on the menu today:

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Syndication: