26

I have an error Microsoft JScript runtime error: ASP.NET Ajax client-side framework failed to load. on a blank page using masterpage

enter image description here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

    <div>

    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="True">
    </asp:ScriptManager>
    </form>
</body>
</html>

This is what it render it the end

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title></head>
<body>
    <form method="post" action="WebForm2.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjE2OTgwNTY5ZGTfWA/dEX85PXBlbkKsVxeLKyIn+mJQ9piW5cbeNE+qww==" />
</div>

<script type="text/javascript"> 
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<script src="http://ajax.microsoft.com/ajax/4.0/2/WebForms.js" type="text/javascript"></script>


<script src="/ScriptResource.axd?d=6x_aX-LOcgUU-O_K6nM7ST5ViC_naT1e4_j-CY35ASRLpcKYpiapwTARuePHvx3llP-Xhl_AG_ubpM1BzkM5iyn9ThB3m7lmXKvkck0cxTcYiT-VbeKgamKxp9EwxBUyIQN6sSCU9SQm3tMtmzQWRg2&amp;t=ffffffffbad362a4" type="text/javascript"></script>
<script type="text/javascript"> 
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>

<script src="/ScriptResource.axd?d=khKEuZ4oUqBYvQxJ1ISpPVIW8_AWWc907q5_v74DI2ruWKTJpldq2osxPkAZ__hffe1Q6HTQUyTbL3Q1mD6MX7V65O5ibxKwb4NvN6ycdZ8vEJ-bz51MO-8uoaP2xioK6npm5n8vldI1d0sOCnH6yw2&amp;t=ffffffffbad362a4" type="text/javascript"></script>

    <div>

    </div>
    <script type="text/javascript"> 
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', 'form1', [], [], [], 90, '');
//]]>
</script>

    </form>
</body>
</html>

The problems might be that i used to have AjaxControlToolkit in my project but later i use jquery instead. so somewhere in the project might try to add Ajaxcontroltoolkit which i can't find it. i don't know how to fix this error. i have tried to add bin file of ajaxcontroltoolkit back but it seems to not work.

Sarawut Positwinyu
  • 4,974
  • 15
  • 54
  • 80

21 Answers21

47

this solution works for me:

The error on client was:

SCRIPT5022: ASP.NET Ajax client-side framework failed to load.

SCRIPT5009: 'Sys' is undefined

After many time to mining the websites, and more solutions, i solve the problem:

the solution for .NET 4.0 is:

Set EnableCdn property of script manager to true, Like this:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true">

Next Solution and Better Solution is:

add this handler to your web.config

  <system.webServer>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated"/>
      <remove name="ScriptHandlerFactory"/>
      <remove name="ScriptHandlerFactoryAppServices"/>
      <remove name="ScriptResource"/>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </handlers>
  </system.webServer>
mRizvandi
  • 983
  • 1
  • 8
  • 20
  • 2
    You sir, are a saint. I've been trying to fix this for a while now and your solution worked. Thanks! – Jobokai Jan 17 '14 at 15:56
  • Use this if your code deployed to dev, uat or prod and it's not working. My project works like a charm ! ^^ – smshahiran Sep 07 '16 at 03:38
  • 4
    I'm running .NET 4.5, and this (EnableCdn property) is the only solution that worked. I don't know why this isn't marked as the answer. I've been digging for days, and even tried the marked answer on this question to no avail. In my case, the error only happened when running locally, but not when deployed. Question: why is your second solution preferred over EnableCdn? – Hawkeye Jul 13 '17 at 21:00
  • 1
    This also worked for me in .NET 4.5 and Visual Studio 2012. – JCO9 Oct 05 '17 at 12:06
  • 1
    Thanks a lot! Under .NET 4.5, the EnableCdn solution was the only one that worked. I've been trying to fix this for a couple of days now. – Andrés Murman Feb 28 '20 at 02:56
  • enablecdn worked for me. the second solution didn't. I was only getting the error in Firefox, not Edge/Chrome, which seemed extra strange to me. – LairdPleng May 12 '21 at 23:36
21

Sys undefined means that you're not getting the client side files loaded on your browser.

Solution 1:

<add verb="GET"
  path="ScriptResource.axd"
  type="Microsoft.Web.Handlers.ScriptResourceHandler"
  validate="false"/>

Solution 2: If you don't have this, add this too under <assemblies>

<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Solution3: If that doesn't work too, try deleting files from your "bin" folder and rebuild the solution and clear the cache of your browser.

Solution 4: Add this to your web.config

<location path="ScriptResource.axd">
   <system.web>
      <authorization>
         <allow users="*"/>
      </authorization>
   </system.web>
</location>
Ashwin Singh
  • 7,197
  • 4
  • 36
  • 55
  • 3
    where is put this – Sarawut Positwinyu Jul 02 '12 at 07:44
  • 3
    In your web.config under – Ashwin Singh Jul 02 '12 at 07:46
  • 1
    with solution2 i got Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. – Sarawut Positwinyu Jul 02 '12 at 08:05
  • 1
    Do not add solution 2. Try using only solution 1 independently, if it not works than try other solutions, most preferably solution 4 – Ashwin Singh Jul 02 '12 at 08:06
  • It worked after i delete everythings in Bin.. It seems that AjaxControlToolkit.dll is still in the Bin Even i remove that in the project and might cause this problem. – Sarawut Positwinyu Jul 02 '12 at 08:12
  • This problem still happen in subfolder, i don't know why :( – Sarawut Positwinyu Jul 02 '12 at 09:41
  • 1
    This helped me out today, I was having a similar issue using web form authentication in a .NET 4.5 project. Turns out I needed to add this: `` Thanks. – Dropzilla Jun 24 '13 at 19:09
  • 1
    Solution 4 worked for me.. ScriptResource.axd was not given access I guess when we say – Sundara Prabu Jun 19 '14 at 09:06
  • 1
    Ashwin, could you edit **Solution 4** so I can tell where it goes in the **Web.config** file? Thanks. –  May 01 '15 at 17:50
  • I am struggle with this error it just started to show for all webform based website from last 1 or 2 days, I tried above solution but they dont seem to work. every thing works fine on localmachine only issue is with development server https://stackoverflow.com/questions/49227879/asp-net-webform-based-website-shows-error-asp-net-ajax-client-side-framework-f – Learning Mar 12 '18 at 04:40
  • Only fix for .NET 4.5. You should add it to your answer. – Raikol Amaro Apr 22 '20 at 17:49
5

for telerik web resources use this code:

<location path="Telerik.Web.UI.WebResource.axd">
<system.web>
  <authorization>
    <allow users="*"/>
  </authorization>
</system.web>

Piotr
  • 51
  • 1
  • 1
3

I had enabled WebForms Routing and forgot to add the exception for resources:

routes.Ignore("{resource}.axd/{*pathInfo}");
Panos Roditakis
  • 146
  • 1
  • 1
2

Another possible cause is script combining/compression in IE 8 & 9. In web.config at the top level (within Configuration), put

 <system.web.extensions>
       <scripting>
             <scriptResourceHandler enableCompression="false" enableCaching="true" />
    </scripting>
</system.web.extensions>

On your ToolKitScriptManager put CombineScripts=False, e.g.

<asp:ToolkitScriptManager runat="server" CombineScripts="False">
</asp:ToolkitScriptManager>

see http://robmzd.blogspot.com/2010/02/invalid-character-error.html which is where I figured out the problem

John Price
  • 166
  • 1
  • 5
  • Thanks. This solved the problem for me. I had a third party HTTP module altering (localizing) JavaScript content even when it was gzip compressed. Turning compression off, the module is now not corrupting the JavaScript code. – Krisztián Balla Dec 02 '13 at 12:23
1

Add EnableScriptCombine="False" to your RadScriptManager as follows:

<telerik:RadScriptManager ID="RadScriptManager1" EnableScriptCombine="False" runat="server" />

Marco Lackovic
  • 6,077
  • 7
  • 55
  • 56
1

I had this problem when I moved my forms to a new server. I spent hours to find the solution. The problem was that the new server has ASP.NET 4.0 and my web.config was ASP.NET 3.5. So I made a new web.config and everything is ok now.

Hibat
  • 11
  • 2
1

Simply add the <handlers> section as shown below in your web.config within <system.webServer> and this will fix the problem in no time.

<system.webServer>
.
.
.
<handlers>
  <remove name="WebServiceHandlerFactory-Integrated"/>
  <remove name="ScriptHandlerFactory"/>
  <remove name="ScriptHandlerFactoryAppServices"/>
  <remove name="ScriptResource"/>
  <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
1

For me it was the problem with Global.asax code,

Just check below condition before validating session in Application_PreRequestHandlerExecute

Request.Path.ToUpper() != Constants.AliasName.ToUpper() + "SCRIPTRESOURCE.AXD"

Functional code is shown below,

protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
        {
            if ((Request.Path != Constants.DebugLoginUrl) &&
                (Request.Path != Constants.SessionTimeOut) &&
                (Request.Path.ToUpper() != Constants.AliasName.ToUpper() + "TRACE.AXD") && 
                (Request.Path.ToUpper() != Constants.AliasName.ToUpper() + "SCRIPTRESOURCE.AXD"))
            {
                // to prevent check of HTTP HANDLER FLUSH - Session State is Invalid
                if (HttpContext.Current.Session != null)
                {
                    if (Session[Constants.personId] == null)
                    {
                    //your code
                    }

                else
                {
                    Response.Redirect(Constants.SessionTimeOut);
                }
            }
        }
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Amit Hiras
  • 21
  • 2
0

In my case the Ajax loading error occurred only if I reloaded the page, not when the page was loaded for the first time.

Looking at the content in the tag in Site.Master, I noticed that only some of the items had Path attribute set. So, I updated MsAjaxBundle to this: and the problem went away. I also had to modify the WebFormsBundle the same way and now reloading the page works.

kj_fi
  • 1
  • 1
0

What worked for me was to download ASP.NET Ajax from Microsoft.

You might also need to explicitly browse for the correct dll version when you add reference e.g.

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Web.Extensions.dll
BornToCode
  • 9,495
  • 9
  • 66
  • 83
0

I set Application Pool as ASP.NET 4.0 Classic during installation.

atiquratik
  • 1,296
  • 3
  • 27
  • 34
oles
  • 1
0

well i just changed RadScriptManger to Simple asp:ScriptManager and it works

Before:

<telerik:RadScriptManager ID="RadScriptManager1" EnableCdn="true" runat="server" />

After

<asp:ScriptManager ID="scrReg" EnablePartialRendering="true" runat="server"></asp:ScriptManager>

Hope it helps

dotnetom
  • 24,551
  • 9
  • 51
  • 54
0

And here's another cause. I installed MySQL Connector/net 6.9.5. Later I started getting the dreaded 'sys undefined' for everything in some, but not all, projects in IE. Many, many hours later I tried Chrome and Opera and the first page opened fine but on post back all the session variables had vanished. That's when the penny finally dropped - Connector/net must have set itself up the session state provider but I had nothing for session state in web.config for the failing projects. Sessionstate inproc fixed it immediately. At least I think that's what happened...

0

In my case, I had ended up with the mentioned handlers in <httpHandlers> as well as in <handlers>. Removing the <httpHandlers> section fixed it.

Justin
  • 131
  • 2
  • 2
0

After adding System.Web.MVC reference to my ASP.NET and added default route in global.asax i.e.

RouteTable.Routes.MapRoute("Default", "{controller}/{action}/{id}",
                                       new { controller = "new", action = "Index", id = "" });
        }

Started getting the error

Added below line to global.asax.cs to resolve it

  RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Manish
  • 59
  • 2
0

For anyone working with the Visual Studio 2015 ASP.NET 4.5 WebForms Web Application project template which bundles the ASP.NET AJAX scripts:

https://stackoverflow.com/a/47673606/313935

dpant
  • 1,622
  • 19
  • 30
0

for me web config was correct. if web config is correct then. check your IIS App pool settings in my case App pool pipeline was selected as the classic I made pipeline integrated and it started working.

Go to iis -> rightclick on your application pool -> advance settings -> Managed Pipelined Mode -> "integrated" -> ok

Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105
ankita
  • 1
0

I am using Visual Studio 2015 ASP.NET 4.5 Web Forms Web Application project and apparently a bad route in an API Controller will also cause this error. I fixed the route and the error went away. It certainly would be nice for a more descriptive error message as to why the client framework won't load. I spent hours checking web.config settings, clearing the .net temporary directories, checking global.ascx, etc.. The strange thing is while IE 11 died while loading default.aspx, chrome was able to load default.aspx and the web site.

firebird
  • 21
  • 2
0

Try changing on the web.config the compilation to false:

<compilation debug="false" targetFramework="4.5">
0

If none of these answers work for you then you might be in my situation. Ok, so for me the issue was caused by the ssl certificate expiring today, so after I renewed it then these errors went away.

Bogdan T Stancu
  • 404
  • 5
  • 6