28

I got a complicated problem with ASP.Net 4.0 Ajax....I started a website with Visual Studio 2010 on my machine,and added some update panels they used to work fine,but suddenly i got that series of errors when i run my website

Microsoft JScript runtime error: ASP.NET Ajax client-side framework failed to load.

Microsoft JScript runtime error: 'Sys' is undefined

The strange things is that i made a website on the same machine with VS 2010 and the update panels there work perfectly.i took its web.config to my new website and changed just the connection..and i got the same error

I tried to search for a solution but i failed to find any real solution.Can anyone help?

Community
  • 1
  • 1
Khaled
  • 841
  • 3
  • 13
  • 22
  • Such a helpful post, I've gotten this problem on more than one occasion and used multiple answers here to solve it. Thank you SO community! – johntrepreneur Oct 25 '13 at 22:17
  • 3
    not sure why it was closed based it's usefulness for me and all the positive SO community feedback. In this case, I don't think it's justified by all the community upvotes. – johntrepreneur Oct 25 '13 at 22:20
  • 1
    I've changed DefaultAppPool's Managed Pipeline Mode from 'Classic' to 'Integrated' and it worked for me. I can't say any common configuration changes with you but it might work for you too. – smlnl Apr 22 '14 at 10:01

13 Answers13

35

Here is the answer by zhughes from this thread on asp.net forum.

The Reason : the path of the javascript generated by the scriptmanager changes when the URL Routing module is used.

The Solution : Tell the routing API to not route the files with "axd" extension (the files generated by the scriptmanager)

Add this rule to the method where you register the routing rules in Global.asax

 routes.Ignore("{resource}.axd/{*pathInfo}");

in addition you should have this section in web.config

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
Khaled
  • 841
  • 3
  • 13
  • 22
  • 1
    routes.Ignore("{resource}.axd/{*pathInfo}"); must appear 1st and before routes.MapPageRoute("RootPages", "{file}", "~/{file}.aspx"); – Paul Jul 31 '11 at 17:25
  • This got rid of my JS errors but the AJAX still isn't working at all. It looks like it's hitting what I want in the response but no output. Any thoughts? – balexander Feb 09 '12 at 01:51
  • I wouldn't run runAllManagedModulesForAllRequests="true" - could be a big hit to performance. http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html – strongriley Jun 05 '12 at 14:50
  • 3
    I am stucking on this problem for a week.. Thank you. – Sarawut Positwinyu Jul 12 '12 at 08:42
  • This was not the solution for me, but check out http://stackoverflow.com/questions/3853208/asp-net-ajax-client-side-framework-failed-to-load-net-4-0 which was – Grandizer Oct 30 '12 at 18:19
  • Three years later, this answer is still saving people's butts. I would +1 this a thousand times if I could. – MadHenchbot Feb 20 '13 at 23:33
  • 1
    "closed as too localized"?!? huh? – Jim W May 02 '13 at 17:37
  • Awesome. Too many times I search for a problem and see everyone saying "thanks, it worked!", but it never works for me. This worked for me! Maybe worth noting that I am using VS2013 and have implemented MVC 5 within a Webforms app. – oscilatingcretin Feb 26 '15 at 18:57
  • anybody can explain me how can i use ; routes.Ignore("{resource}.axd/{*pathInfo}"); in global.asax ? – Ilaria Jan 27 '20 at 13:19
10

if you using URL rewrite module, then in each rewrite rule add

<add input="{URL}" pattern="\.axd$" negate="true"/>

under conditions tag, like this:

<rule name="HomeRewrite" stopProcessing="true">
   <match url="^home$"/>
   <conditions>
     <add input="{URL}" pattern="\.axd$" negate="true"/>
   </conditions>
   <action type="Rewrite" url="/home.aspx"/>
</rule>
Safran Ali
  • 4,477
  • 9
  • 40
  • 57
8

I have found that this is a possibly a caching/compression issue and by putting in the following into Web.Config, resolves the issue.

<system.web.extensions>
    <scripting>
      <scriptResourceHandler enableCaching="false" enableCompression="false" />
    </scripting>
</system.web.extensions>
Chris Hammond
  • 81
  • 1
  • 1
  • while this did get rid of the error for me (+1), it doesn't seem ideal to disable caching. – johntrepreneur Oct 25 '13 at 22:11
  • although not ideal, this answer was my fallback for now, but after trying kannankeril's solution about repairing the 'installed program' --> 'MS .NET Framework 4 Client Profile', it removed the problem permanently for me. – johntrepreneur Oct 25 '13 at 22:15
3

I was having the same problem. I installed VS 2010 SP1 and the problem went away.

user735232
  • 181
  • 2
  • 6
3

I had the same problem and I solved it by run the command aspnet_regiis -i on the folder of the Framework 4.0 (on which my application ran). It was a problem on the Handler Mapping of IIS: this operation fix the problem for me. See also this post.

Hope this could be helpful.

ste.xin
  • 386
  • 1
  • 4
3

Microsoft JScript runtime error: ASP.NET Ajax client-side framework failed to load.

Add reference like this..

<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>              
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Tim S. Van Haren
  • 8,861
  • 2
  • 30
  • 34
kumar
  • 31
  • 1
3

It may be simply missing part in your web.config like the <Handlers> of <httpHandlers>, my advice is if you have old copy of your web config try it out.

Tim S. Van Haren
  • 8,861
  • 2
  • 30
  • 34
Tarek El-Mallah
  • 4,015
  • 1
  • 31
  • 46
2

This is a common error that happens when you try to call framework javascript function before page have even loaded them.

So ether run your code when dom is ready (eg pageload), ether place your code after the scriptmanager tag, or check to place it after the javascript load from scriptmanager.

Aristos
  • 66,005
  • 16
  • 114
  • 150
  • How can i do that? and yes the script manager is in the top of my master page,but even when i created a new blank page,with only a label and a button in an update panel,,i received the same error – Khaled Sep 12 '10 at 22:22
  • @khaled can you see the source code of your page (right click on browser and select source code). Then check the line that you get the error. Maybe there are elements in your page that you have setup them on web.config ? – Aristos Sep 13 '10 at 05:15
  • @Aristos thanks for your reply,i tried to bug the page with firebug and changed the line which fire the error after all the scripts references,,that did not let all the page post back when a control in an update panel posts back..it happens with no action...i started a new blank website and imported my pages,app_code and BIN folders..it worked fine,,but later again without changing anything i got the same error. :( – Khaled Sep 13 '10 at 22:40
  • @khaled Do you use gzip ? for compressing your page ? – Aristos Sep 14 '10 at 06:37
  • @Aristos No at all..i reinstalled the VS 2010 on my machine and even tried to open the website on another machine that has VS 2010 and i got the same error.I am really frustrated from that strange error! – Khaled Sep 14 '10 at 22:50
  • @khaled there is a case that your web.config is not setup the right way. Search on google for the "Ajax client-side framework failed to load". – Aristos Sep 15 '10 at 08:08
  • @Aristos i tired that already,but you now in Asp.Net 4.0 the web.config is cleaner than the previous versions,i have not changed anything in the web.config,and all the related posts i found through Google about previous versions. :( ,Thanks for your attention – Khaled Sep 15 '10 at 12:53
  • @Aristos i found a post on Asp.Net forum,the post said that after adding routing to the website it started to show that error,i removed all the related code to routing and now there are no errors and ajax works fine,What could be the reason as i want them both to work? – Khaled Sep 16 '10 at 13:15
  • @khaled maybe is lost the path of the WebResource.axd file from the rules of the routing. You can open the page of the render html and see where is search to locate the WebResource - if this is not found then the library with javascript is not loaded and the sys not found error appear. – Aristos Sep 16 '10 at 13:32
  • @Artistos,,yeh it is the reason,,the routing messes the reference,,i am searching for a solution – Khaled Sep 16 '10 at 13:49
2

I had this problem and sought an answer from the almighty Google, tried various suggestions including the ones above but had no luck. Gave up and moved on to other work, came back a few days later and the problem had disappeared.

I resumed work, made some code changes and published my website and the problem reappeared. Went back to the Google and came across someone who had the problem while using the 3.5 framework. In that case s/he was able to resolve the problem by going to the 'Add/Remove Programs' control panel and selecting the repair option.

I did likewise, repairing the 'MS .NET Framework 4 Client Profile' and 'MS .NET Framework 4 Extended'. That fixed the problem for me.

Hope that solves it for someone else.

2

in my case, it's IISExpress, switch back to the cassini dev server fix my headache.

koo9
  • 409
  • 5
  • 15
  • How did you do this? I'm in VS2012, and once IIS Express has grabbed onto my website, I can't get VS2012 use Cassini for this website anymore! – jimtut Aug 09 '13 at 17:43
1
  1. If .Net Framework 4.0 client Profile is not available in your machine , so repair .net Frame work 4.0 or re install .
  2. go to Project Property and select target framework 3.5.
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
1

In my case it was the UrlScan tool by Microsoft that was rejecting some URL's requested by Ajax. Disabling it solved the problem.

Basil
  • 11
  • 1
1

I had this problem as well dealing with a master page and in my case it was a "Base" meta setting that was messing me up. I do recall reading another article/blog somewhere where they mentioned an issue with ajax validation across different domains causing this type of error.

So in my case, I had a <base...> reference setting the default url for the site but my dev was obviously a different url...thus conflict and the "ASP.NET Ajax client-side framework failed to load." error.

Removed the base and voila...error gone.

HTH

Dave

Dave
  • 740
  • 1
  • 6
  • 17