[asp.net] Sys is undefined

I have an ASP.Net/AJAX control kit project that i am working on. 80% of the time there is no problem. The page runs as it should. If you refresh the page it will sometimes show a javascript error "Sys is undefined".

It doesn't happen all the time, but it is reproducible. When it happens, the user has to shut down their browser and reopen the page.

This leads me to believe that it could be an IIS setting.

Another note. I looked at the page source both when I get the error, and when not. When the page throws errors the following code is missing:

<script src="/ScriptResource.axd?d=EAvfjPfYejDh0Z2Zq5zTR_TXqL0DgVcj_h1wz8cst6uXazNiprV1LnAGq3uL8N2vRbpXu46VsAMFGSgpfovx9_cO8tpy2so6Qm_0HXVGg_Y1&amp;t=baeb8cc" 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>

This question is related to asp.net javascript asp.net-ajax

The answer is


This is going to sound stupid but I had a similar problem with a site being developed in VS2010 and hosted in the VS Dev Server. The page in question had a scriptmanager to create the connection to a wcf service. I added an extra method to the service and this error started appearing.

What fixed it for me was changing from 'Auto-assign Port' to 'Specific port' with a different port number in the oroject Web settings.

I wish I knew why...


I had similar problems and to my surprise what I found that one of my developer had saved web.config in the same folder/solution as web123.config and by mistake both of these files were uploaded.

As soon as I deleted the web123.config file, this error disappeared and ajax framework was loading correctly. even though I have

<compilation debug="true">

In my case I also have following segment. My project is using framework 3.5

    <httpHandlers>
  <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
  <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>

In my case the problem was that I had putted the following code to keep the gridview tableheader after partial postback:

    protected override void OnPreRenderComplete(EventArgs e)
    {
        if (grv.Rows.Count > 0)
        {
            grv.HeaderRow.TableSection = TableRowSection.TableHeader;
        }
    }

Removing this code stopped the issue.


I don't think this point has been added and since I just spent some time hunting this down I hope it can help.

I am working with IIS 7 and using the ASP.NET v4 Framework.
In my case it was important that an entry be added to both the and section of the entry in the web.config file.

My web.config file has a lot of handlers and in my case it was easiest to add the ScriptResources entry to the top of the handlers section. Most importantly, it needs to be placed before any entry that will act as a wildcard and capture the request. Adding it after a wildcard entry will cause it to be ignored and the error will still appear.

The module can be added to the top or bottom of the section.

Web.config Sample:

<system.webServer>
    <handlers>
      <clear />
      <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" />
      <!-- Make sure wildcard rules are below the ScriptResource tag -->
    </handlers>
    <modules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <!-- Other modules are added here -->
    </modules>
  </system.webServer>

This is going to sound stupid but I had a similar problem with a site being developed in VS2010 and hosted in the VS Dev Server. The page in question had a scriptmanager to create the connection to a wcf service. I added an extra method to the service and this error started appearing.

What fixed it for me was changing from 'Auto-assign Port' to 'Specific port' with a different port number in the oroject Web settings.

I wish I knew why...


Development Environment:
  • Dev-Env: VS 2012
  • FX: 4.0/4.5
  • Implementations: Master(ScriptManager + UpdatePanel/Timer) + Content (UpdatePanel)
  • Patterns: PageRouting.

Disclaimer:

If all the web.config solutions do not work for you and you have implemented PageRouting (IIS 7+), then the code snippet below will solve your problems.

Background:

Dont mean to Highjack this question but had the same problem as everyone else and implemented 100% of the suggestions here, with minor modifications for .Net 4.0/4.5, and none of them worked for me.

In my situation i had implemented Page Routing which was ghosting my problem. Basically it would work for about 20, or so, debug runs and then BAM would error out with the Sys is undefined error.

After reviewing a couple other posts, that got to talking about the Clean-URL logic, i remembered that i had done PageRouting setup's.

Here is the resource i used to build my patterns: Page Routing

My one-liner code fixed my VS2012 Debugging problem:

rts.Ignore("{resource}.axd/{*pathInfo}")    'Ignores any Resource cache references, used heavily in AJAX interactions.

Make sure you don't have any Rewrite rules that change your url.

In my case the application thought it was only level deeper then the url reached.

Example: http://mysite.com/app/page.aspx was the real url. But i cut off /app/ this worked fine for ASP.net and WCF, but clearly not for Ajax.


Make sure that any client scripts you have that interact with .NET AJAX have the following line at the end:

if (typeof(Sys) !== 'undefined')  Sys.Application.notifyScriptLoaded();

This tells the script manager that the whole script file has loaded and that it can begin to call client methods


Dean L's answer, https://stackoverflow.com/a/1718513/292060 worked for me, since my call to Sys was also too early. Since I'm using jQuery, instead of moving it down, I put the script inside a document.ready call:

$(document).ready(function () {
  Sys. calls here
});

This seems to be late enough that Sys is available.


I had similar problems and to my surprise what I found that one of my developer had saved web.config in the same folder/solution as web123.config and by mistake both of these files were uploaded.

As soon as I deleted the web123.config file, this error disappeared and ajax framework was loading correctly. even though I have

<compilation debug="true">

In my case I also have following segment. My project is using framework 3.5

    <httpHandlers>
  <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
  <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>

Try setting your ScriptManager to this.

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

I had same probleme but i fixed it by:

When putting a script file into a page, make sure it is

<script></script> and not <script />.

I have followed this: http://forums.asp.net/t/1742435.aspx?An+element+with+id+form1+could+not+be+found+Script+error+on+page+load

Hope this will help


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.


In addition to ensuring you have the ScriptManager on your page you need to ensure that your web.config is appropriately configured.

When ASP.NET AJAX 1.0 was released (for .NET 2.0) there was a lot of custom web.config settings which added handlers, controls, etc.

You'll find the config info here: http://www.asp.net/AJAX/documentation/live/ConfiguringASPNETAJAX.aspx


Make sure that any client scripts you have that interact with .NET AJAX have the following line at the end:

if (typeof(Sys) !== 'undefined')  Sys.Application.notifyScriptLoaded();

This tells the script manager that the whole script file has loaded and that it can begin to call client methods


When I experienced the errors

  • Sys is undefined
  • ASP.NET Ajax client-side framework failed to load

in IE when using ASP.NET Ajax controls in .NET 2.0, I needed to add the following to the web.config file within the <system.web> tags:

<httpHandlers>
  <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>

Just create blank .axd files in your solutions root foder problem will be resolved. (2 file: scriptresouce.asx, webresource.asxd)


You must add these lines in the web.config

<httpHandlers>
  <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
  <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>

Hope this helps.


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.


I have been seeing the exact same error today, but it was not a config or direct JavaScript issue.

An external .net project had been updated but the changes not picked up properly in the compilation of the web site. My presumption is that ASP.NET ajax was not able to construct the client representations of the .NET objects properly and so was failing to load correctly.

To resolve, I rebuilt the external project(s), and rebuilt my solution that was experiencing issues. The problem went away.


Even after adding the correct entry for web config still getting this error ? most common reason for this error is JavaScript that references the Sys namespace too early. Then most obvious fix would be move the java script block below the ScriptManager control:


I fixed my problem by moving the <script type="text/javascript"></script> block containing the Sys.* calls lower down (to the last item before the close of the body's <asp:Content/> section) in the HTML on the page. I originally had my the script block in the HEAD <asp:Content/> section of my page. I was working inside a page that had a MasterPageFile. Hope this helps someone out.


Add

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); 

Please check enter link description here


Try setting your ScriptManager to this.

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

Dean L's answer, https://stackoverflow.com/a/1718513/292060 worked for me, since my call to Sys was also too early. Since I'm using jQuery, instead of moving it down, I put the script inside a document.ready call:

$(document).ready(function () {
  Sys. calls here
});

This seems to be late enough that Sys is available.


Even after adding the correct entry for web config still getting this error ? most common reason for this error is JavaScript that references the Sys namespace too early. Then most obvious fix would be move the java script block below the ScriptManager control:


In my case, I've found a very hidden reason ... There was this page route with in Global.ascx.cs which doesn't appear in my tests in sub-folders but returns the question error all the time .. another day with strange issues.

routes.MapPageRoute("siteDefault", "{culture}/", "~/default.aspx", false, new RouteValueDictionary(new { culture = "(\\w{2})|(\\w{2}-\\w{2})" }));

I was having this same issue and after much wrangling I decided to try and isolate the problem and simply load the script manager in an empty page which still resulted in this same error. Having isolated the problem I discovered through a comparison of my site's web.config with a brand new (working) test site that changing <compilation debug="true"> to <compilation debug="false"> in the system.web section of my web.config fixes the problem.

I also had to remove the <xhtmlConformance mode="Legacy"/> entry from system.web to make the update panel work properly. Click here for a description of this issue.


In case none of the above works for you, and you happen to be overriding OnPreRenderComplete, make sure you call base.OnPreRenderComplete. My therapist is going to be happy to see me back


I had the same problem after updating my AjaxControlToolkit.dll to the latest version 4.1.7.725 from 4.1.60623.0. I've searched and came up to this page, but none of the answers help me. After looking to the sample website of the Ajax Control Toolkit that is in the CodePlex zip file, I have realized that the <asp:ScriptManager> replaced by the new <ajaxtoolkit:ToolkitScriptManager>. I did so and there is no Sys.Extended is undefined any more.


You must add these lines in the web.config

<httpHandlers>
  <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
  <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>

Hope this helps.


I had the same problem after updating my AjaxControlToolkit.dll to the latest version 4.1.7.725 from 4.1.60623.0. I've searched and came up to this page, but none of the answers help me. After looking to the sample website of the Ajax Control Toolkit that is in the CodePlex zip file, I have realized that the <asp:ScriptManager> replaced by the new <ajaxtoolkit:ToolkitScriptManager>. I did so and there is no Sys.Extended is undefined any more.


I hate adding to such a huge topic and so much later, but I've think I have a solution that work in VS2015 at the very least.

I was on a hunt to find a reason for the sys error, and the only solution that worked for me was to add EnableCdn="true" in a ScriptManager like this:

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

See the MSDN for more information.

Why do we need to do this?

When working on a asp.net web application, you have to enable CDN so that Microsoft can download the Sys. library.

There was probably a script in your page that was using the Sys function. Setting EnableCdn="true" would ensure that the Sys library is downloaded before it is used.

What's CDN?

A quote from https://www.sitepoint.com/7-reasons-to-use-a-cdn/

Most CDNs are used to host static resources such as images, videos, audio clips, CSS files and JavaScript. You’ll find common JavaScript libraries, HTML5 shims, CSS resets, fonts and other assets available on a variety of public and private CDN systems.

Both Google and Microsoft have CDNs. All you have to do is add a reference. Usually CDNs are added via a script resource:

<script src="https://ajax.aspnetcdn.com/ajax/4.5.1/1/MicrosoftAjax.js" type="text/javascript"></script>

Once you set EnableCdn="true" and Microsoft will add it's little CDN reference (like the one above) in the page which downloads the Sys library.

I hope that helps anybody that ran into the same issue.


I solved this problem by creating separate asp.net ajax solution and copy and paste all ajax configuration from web.config to working project.

here are the must configuration you should set in web.config

    <configuration>
<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>

    </sectionGroup>
</configSections>

        <assemblies>

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

        </assemblies>
           </compilation>
        <httpHandlers>
        <remove verb="*" path="*.asmx"/>
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>
    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>
</system.web>
    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
        <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </modules>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated"/>
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.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=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </handlers>
</system.webServer>

I found the error when using a combination of the Ajax Control Toolkit ToolkitScriptManager and URL Write 2.0.

In my <rewrite> <outboundRules> I had a precondition:

<preConditions>
    <preCondition name="IsHTML">
        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html"/>
    </preCondition>
</preConditions>

But apparently some of my outbound rules weren't set to use the precondition.

Once I had that preCondition set on all my outbound rules:

<rule preCondition="IsHTML" name="MyOutboundRule">

No more problem.


I know this is an old thread but I found a somewhat unique solution. In my case I was getting the error because I am using both Webforms and MVC in the same ASP.NET web application. After mapping routes the issue showed up. I fixed it by adding the following code to ignore routes for both "{resource}.aspx/{*pathInfo}" and "{resource}.axd/{*pathInfo}"

    private void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
           "Default", 
           "{controller}/{action}/{id}", 
           new { controller = "Test", action = "Index", id = UrlParameter.Optional }
       );
    }

Make sure that any client scripts you have that interact with .NET AJAX have the following line at the end:

if (typeof(Sys) !== 'undefined')  Sys.Application.notifyScriptLoaded();

This tells the script manager that the whole script file has loaded and that it can begin to call client methods


Just create blank .axd files in your solutions root foder problem will be resolved. (2 file: scriptresouce.asx, webresource.asxd)


In addition to ensuring you have the ScriptManager on your page you need to ensure that your web.config is appropriately configured.

When ASP.NET AJAX 1.0 was released (for .NET 2.0) there was a lot of custom web.config settings which added handlers, controls, etc.

You'll find the config info here: http://www.asp.net/AJAX/documentation/live/ConfiguringASPNETAJAX.aspx


Try setting your ScriptManager to this.

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

I was using telerik and had exactly same problem.

adding this to web.config resolved my issue :)

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

maybe it will help you too. it was Authentication problem.

Source


I had same probleme but i fixed it by:

When putting a script file into a page, make sure it is

<script></script> and not <script />.

I have followed this: http://forums.asp.net/t/1742435.aspx?An+element+with+id+form1+could+not+be+found+Script+error+on+page+load

Hope this will help


Make sure you don't have any Rewrite rules that change your url.

In my case the application thought it was only level deeper then the url reached.

Example: http://mysite.com/app/page.aspx was the real url. But i cut off /app/ this worked fine for ASP.net and WCF, but clearly not for Ajax.


Development Environment:
  • Dev-Env: VS 2012
  • FX: 4.0/4.5
  • Implementations: Master(ScriptManager + UpdatePanel/Timer) + Content (UpdatePanel)
  • Patterns: PageRouting.

Disclaimer:

If all the web.config solutions do not work for you and you have implemented PageRouting (IIS 7+), then the code snippet below will solve your problems.

Background:

Dont mean to Highjack this question but had the same problem as everyone else and implemented 100% of the suggestions here, with minor modifications for .Net 4.0/4.5, and none of them worked for me.

In my situation i had implemented Page Routing which was ghosting my problem. Basically it would work for about 20, or so, debug runs and then BAM would error out with the Sys is undefined error.

After reviewing a couple other posts, that got to talking about the Clean-URL logic, i remembered that i had done PageRouting setup's.

Here is the resource i used to build my patterns: Page Routing

My one-liner code fixed my VS2012 Debugging problem:

rts.Ignore("{resource}.axd/{*pathInfo}")    'Ignores any Resource cache references, used heavily in AJAX interactions.

I was using telerik and had exactly same problem.

adding this to web.config resolved my issue :)

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

maybe it will help you too. it was Authentication problem.

Source


In case none of the above works for you, and you happen to be overriding OnPreRenderComplete, make sure you call base.OnPreRenderComplete. My therapist is going to be happy to see me back


Was having a similar issue, except that my page was consistently generating the Sys is undefined error.

For me the problem stems from the fact that I've just installed the AJAX 1.0 extension for .NET 2.0 but had already created my web project in Visual Studio.

When tried to create AJAX controls I kept encountering this error, I spotted Slace's and MadMax1138s posts here. And figured it was my web.config, I created a new project using the new "AJAX enabled web site" project type, and sure enough the web.config has a large number of customizations necessary to use the AJAX controls.

I just updated that web.config with the web.config updates I had already made myself and dropped it into my existing project and everything worked fine.


I have been seeing the exact same error today, but it was not a config or direct JavaScript issue.

An external .net project had been updated but the changes not picked up properly in the compilation of the web site. My presumption is that ASP.NET ajax was not able to construct the client representations of the .NET objects properly and so was failing to load correctly.

To resolve, I rebuilt the external project(s), and rebuilt my solution that was experiencing issues. The problem went away.


I solved this problem by creating separate asp.net ajax solution and copy and paste all ajax configuration from web.config to working project.

here are the must configuration you should set in web.config

    <configuration>
<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>

    </sectionGroup>
</configSections>

        <assemblies>

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

        </assemblies>
           </compilation>
        <httpHandlers>
        <remove verb="*" path="*.asmx"/>
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>
    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>
</system.web>
    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
        <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </modules>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated"/>
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.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=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </handlers>
</system.webServer>

I know this is an old thread but I found a somewhat unique solution. In my case I was getting the error because I am using both Webforms and MVC in the same ASP.NET web application. After mapping routes the issue showed up. I fixed it by adding the following code to ignore routes for both "{resource}.aspx/{*pathInfo}" and "{resource}.axd/{*pathInfo}"

    private void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
           "Default", 
           "{controller}/{action}/{id}", 
           new { controller = "Test", action = "Index", id = UrlParameter.Optional }
       );
    }

When I experienced the errors

  • Sys is undefined
  • ASP.NET Ajax client-side framework failed to load

in IE when using ASP.NET Ajax controls in .NET 2.0, I needed to add the following to the web.config file within the <system.web> tags:

<httpHandlers>
  <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>

Make sure that any client scripts you have that interact with .NET AJAX have the following line at the end:

if (typeof(Sys) !== 'undefined')  Sys.Application.notifyScriptLoaded();

This tells the script manager that the whole script file has loaded and that it can begin to call client methods


In addition to ensuring you have the ScriptManager on your page you need to ensure that your web.config is appropriately configured.

When ASP.NET AJAX 1.0 was released (for .NET 2.0) there was a lot of custom web.config settings which added handlers, controls, etc.

You'll find the config info here: http://www.asp.net/AJAX/documentation/live/ConfiguringASPNETAJAX.aspx


I hate adding to such a huge topic and so much later, but I've think I have a solution that work in VS2015 at the very least.

I was on a hunt to find a reason for the sys error, and the only solution that worked for me was to add EnableCdn="true" in a ScriptManager like this:

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

See the MSDN for more information.

Why do we need to do this?

When working on a asp.net web application, you have to enable CDN so that Microsoft can download the Sys. library.

There was probably a script in your page that was using the Sys function. Setting EnableCdn="true" would ensure that the Sys library is downloaded before it is used.

What's CDN?

A quote from https://www.sitepoint.com/7-reasons-to-use-a-cdn/

Most CDNs are used to host static resources such as images, videos, audio clips, CSS files and JavaScript. You’ll find common JavaScript libraries, HTML5 shims, CSS resets, fonts and other assets available on a variety of public and private CDN systems.

Both Google and Microsoft have CDNs. All you have to do is add a reference. Usually CDNs are added via a script resource:

<script src="https://ajax.aspnetcdn.com/ajax/4.5.1/1/MicrosoftAjax.js" type="text/javascript"></script>

Once you set EnableCdn="true" and Microsoft will add it's little CDN reference (like the one above) in the page which downloads the Sys library.

I hope that helps anybody that ran into the same issue.


I fixed my problem by moving the <script type="text/javascript"></script> block containing the Sys.* calls lower down (to the last item before the close of the body's <asp:Content/> section) in the HTML on the page. I originally had my the script block in the HEAD <asp:Content/> section of my page. I was working inside a page that had a MasterPageFile. Hope this helps someone out.


In my case, I've found a very hidden reason ... There was this page route with in Global.ascx.cs which doesn't appear in my tests in sub-folders but returns the question error all the time .. another day with strange issues.

routes.MapPageRoute("siteDefault", "{culture}/", "~/default.aspx", false, new RouteValueDictionary(new { culture = "(\\w{2})|(\\w{2}-\\w{2})" }));

Try one of this solutions:

1. The browser fails to load the compressed script

This is usually the case if you get the error on IE6, but not on other browsers.

The Script Resource Handler – ScriptResource.axd compresses the scripts before returning them to the browser. In pre-RTM releases, the handler did it all the time for all browsers, and it wasn’t configurable. There is an issue in one of the components of IE6 that prevents it from loading compressed scripts correctly. See KB article here. In RTM builds, we’ve made two fixes for this. One, we don’t compress if IE6 is the browser client. Two, we’ve now made compression configurable. Here’s how you can toggle the web.config.

How do you fix it? First, make sure you are using the AJAX Extensions 1.0 RTM release. That alone should be enough. You can also try turning off compression by editing your web.config to have the following:

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

2. The required configuration for ScriptResourceHandler doesn’t exist for the web.config for your application

Make sure your web.config contains the entries from the default web.config file provided with the extensions install. (default location: C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025)

3. The virtual directory you are using for your web, isn’t correctly marked as an application (thus the configuration isn’t getting loaded) - This would happen for IIS webs.

Make sure that you are using a Web Application, and not just a Virtual Directory

4. ScriptResource.axd requests return 404

This usually points to a mis-configuration of ASP.NET as a whole. On a default installation of ASP.NET, any web request to a resource ending in .axd is passed from IIS to ASP.NET via an isapi mapping. Additionally the mapping is configured to not check if the file exists. If that mapping does not exist, or the check if file exists isn't disabled, then IIS will attempt to find the physical file ScriptResource.axd, won't find it, and return 404.

You can check to see if this is the problem by coipy/pasting the full url to ScriptResource.axd from here, and seeing what it returns

<script src="/MyWebApp/ScriptResource.axd?[snip - long query string]" type="text/javascript"></script>

How do you fix this? If ASP.NET isn't properly installed at all, you can run the "aspnet_regiis.exe" command line tool to fix it up. It's located in C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727. You can run "aspnet_regiis -i -enable", which does the full registration of ASP.NET with IIS and makes sure the ISAPI is enabled in IIS6. You can also run "aspnet_regiis -s w3svc/1/root/MyWebApp" to only fix up the registration for your web application.

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

Put this entry under <system.webServer/><handlers/>:

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

and remove the one under <system.web/><httpHandlers/>.

References: http://weblogs.asp.net/chrisri/demystifying-sys-is-undefined http://geekswithblogs.net/lorint/archive/2007/03/28/110161.aspx


Hi thanx a lot it solved my issue ,

By default vs 2008 will add

 <!--<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false" />-->

Need to correct Default config(Above) to below code FIX

 <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>

In addition to ensuring you have the ScriptManager on your page you need to ensure that your web.config is appropriately configured.

When ASP.NET AJAX 1.0 was released (for .NET 2.0) there was a lot of custom web.config settings which added handlers, controls, etc.

You'll find the config info here: http://www.asp.net/AJAX/documentation/live/ConfiguringASPNETAJAX.aspx


I was having this same issue and after much wrangling I decided to try and isolate the problem and simply load the script manager in an empty page which still resulted in this same error. Having isolated the problem I discovered through a comparison of my site's web.config with a brand new (working) test site that changing <compilation debug="true"> to <compilation debug="false"> in the system.web section of my web.config fixes the problem.

I also had to remove the <xhtmlConformance mode="Legacy"/> entry from system.web to make the update panel work properly. Click here for a description of this issue.


In my case the problem was that I had putted the following code to keep the gridview tableheader after partial postback:

    protected override void OnPreRenderComplete(EventArgs e)
    {
        if (grv.Rows.Count > 0)
        {
            grv.HeaderRow.TableSection = TableRowSection.TableHeader;
        }
    }

Removing this code stopped the issue.


Try one of this solutions:

1. The browser fails to load the compressed script

This is usually the case if you get the error on IE6, but not on other browsers.

The Script Resource Handler – ScriptResource.axd compresses the scripts before returning them to the browser. In pre-RTM releases, the handler did it all the time for all browsers, and it wasn’t configurable. There is an issue in one of the components of IE6 that prevents it from loading compressed scripts correctly. See KB article here. In RTM builds, we’ve made two fixes for this. One, we don’t compress if IE6 is the browser client. Two, we’ve now made compression configurable. Here’s how you can toggle the web.config.

How do you fix it? First, make sure you are using the AJAX Extensions 1.0 RTM release. That alone should be enough. You can also try turning off compression by editing your web.config to have the following:

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

2. The required configuration for ScriptResourceHandler doesn’t exist for the web.config for your application

Make sure your web.config contains the entries from the default web.config file provided with the extensions install. (default location: C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025)

3. The virtual directory you are using for your web, isn’t correctly marked as an application (thus the configuration isn’t getting loaded) - This would happen for IIS webs.

Make sure that you are using a Web Application, and not just a Virtual Directory

4. ScriptResource.axd requests return 404

This usually points to a mis-configuration of ASP.NET as a whole. On a default installation of ASP.NET, any web request to a resource ending in .axd is passed from IIS to ASP.NET via an isapi mapping. Additionally the mapping is configured to not check if the file exists. If that mapping does not exist, or the check if file exists isn't disabled, then IIS will attempt to find the physical file ScriptResource.axd, won't find it, and return 404.

You can check to see if this is the problem by coipy/pasting the full url to ScriptResource.axd from here, and seeing what it returns

<script src="/MyWebApp/ScriptResource.axd?[snip - long query string]" type="text/javascript"></script>

How do you fix this? If ASP.NET isn't properly installed at all, you can run the "aspnet_regiis.exe" command line tool to fix it up. It's located in C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727. You can run "aspnet_regiis -i -enable", which does the full registration of ASP.NET with IIS and makes sure the ISAPI is enabled in IIS6. You can also run "aspnet_regiis -s w3svc/1/root/MyWebApp" to only fix up the registration for your web application.

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

Put this entry under <system.webServer/><handlers/>:

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

and remove the one under <system.web/><httpHandlers/>.

References: http://weblogs.asp.net/chrisri/demystifying-sys-is-undefined http://geekswithblogs.net/lorint/archive/2007/03/28/110161.aspx


Add

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); 

Please check enter link description here


I don't think this point has been added and since I just spent some time hunting this down I hope it can help.

I am working with IIS 7 and using the ASP.NET v4 Framework.
In my case it was important that an entry be added to both the and section of the entry in the web.config file.

My web.config file has a lot of handlers and in my case it was easiest to add the ScriptResources entry to the top of the handlers section. Most importantly, it needs to be placed before any entry that will act as a wildcard and capture the request. Adding it after a wildcard entry will cause it to be ignored and the error will still appear.

The module can be added to the top or bottom of the section.

Web.config Sample:

<system.webServer>
    <handlers>
      <clear />
      <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" />
      <!-- Make sure wildcard rules are below the ScriptResource tag -->
    </handlers>
    <modules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <!-- Other modules are added here -->
    </modules>
  </system.webServer>

Hi thanx a lot it solved my issue ,

By default vs 2008 will add

 <!--<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false" />-->

Need to correct Default config(Above) to below code FIX

 <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>

Examples related to asp.net

RegisterStartupScript from code behind not working when Update Panel is used You must add a reference to assembly 'netstandard, Version=2.0.0.0 No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization How to use log4net in Asp.net core 2.0 Visual Studio 2017 error: Unable to start program, An operation is not legal in the current state How to create roles in ASP.NET Core and assign them to users? How to handle Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() ASP.NET Core Web API Authentication Could not load file or assembly 'CrystalDecisions.ReportAppServer.CommLayer, Version=13.0.2000.0 WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery

Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to asp.net-ajax

How to pass multiple parameters from ajax to mvc controller? window.open with target "_blank" in Chrome Setting Access-Control-Allow-Origin in ASP.Net MVC - simplest possible method Disable asp.net button after click to prevent double clicking How can I convince IE to simply display application/json rather than offer to download it? How to send a model in jQuery $.ajax() post request to MVC controller method How to post ASP.NET MVC Ajax form using JavaScript rather than submit button How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET? jQuery $(document).ready and UpdatePanels? ASP.NET MVC controller actions that return JSON or partial html