27

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?

3
  • 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! Oct 25, 2013 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. Oct 25, 2013 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, 2014 at 10:01

13 Answers 13

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>
9
  • 1
    routes.Ignore("{resource}.axd/{*pathInfo}"); must appear 1st and before routes.MapPageRoute("RootPages", "{file}", "~/{file}.aspx");
    – Paul
    Jul 31, 2011 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 9, 2012 at 1:51
  • I wouldn't run runAllManagedModulesForAllRequests="true" - could be a big hit to performance. britishdeveloper.co.uk/2010/06/… Jun 5, 2012 at 14:50
  • 3
    I am stucking on this problem for a week.. Thank you. Jul 12, 2012 at 8:42
  • 1
    "closed as too localized"?!? huh? May 2, 2013 at 17:37
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>
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>
2
  • while this did get rid of the error for me (+1), it doesn't seem ideal to disable caching. Oct 25, 2013 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. Oct 25, 2013 at 22:15
3

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

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.

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.

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"/>
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.

10
  • 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, 2010 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, 2010 at 5: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, 2010 at 22:40
  • @khaled Do you use gzip ? for compressing your page ?
    – Aristos
    Sep 14, 2010 at 6: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, 2010 at 22:50
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.

1
  • 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 9, 2013 at 17:43
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

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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.