Telerik blogs

In this post I will show you how to troubleshoot Web Resource related problems and how to deal with them.

If you are using an ASP.NET server control with rich client-side behavior it is likely built to utilize web resources. Sometimes your page loads and that rich server side control does not work at all - the tree view does not expand, the grid cannot sort etc. Most of the times this is because the JavaScript files of those controls have failed to load. If your browser is configured to prompt on JavaScript errors you may see the following error messages:

  1. "RadTreeView is undefined" if you are using RadControls for ASP.NET (Classic)
  2. "Sys is undefined" or "Telerik is undefined" if you are using RadControls for ASP.NET Ajax (former "Prometheus")

Receiving one of those messages indicates that there is a Web Resource related issue. The next step is to find out what exactly is causing that error message.

Manually requesting the web resource handler

The fastest way would be to view the rendered output of your page and get the URL of the offending script tag. Here is a short demo with RadTreeView Classic:

<div id="RadTreeView1_wrapper"
    <!-- 6.3.5 --><script type="text/javascript" src="/Sample/WebResource.axd?d=mOXVXvUPV2JWSrl55DXbLd4CU3OqV82yycNo3oZC9Qn3B05GrDVSd8t21hVYrCq41DKrZevSapn__c8UQPRmtdYqo9Oc7wmveT4PyIINoBOcBUJOfqTubx1YzP6v6wYp0&amp;t=633437882200000000"></script> 

Then paste that URL in your browser's address bar (after the domain and folder of course). Normally the web server should serve back the content of that web resource. However in case of a problem with the web resource HTTP handler you would see an error page saying that the server returned HTTP error code 404 (not found) or 500 (server error).

Using web development tools to request the web resource handler

Another useful technique is to use an HTTP traffic sniffer tool - Fiddler for Internet Explorer or FireBug for FireFox. Here are two screenshots showing a failed request to a web resource file:




Dealing with the 404 error code (the requested URL was not found)

Please check the following:

  1. Check in the IIS management console that the .axd extension (the default HTTP handler extension) is allowed:
  2. Also check if the “Verify if file exists” checkbox is unchecked. This screen appears after you click the "Edit" button appearing in the previous screenshot:

  3. If you are using RadControls for ASP.NET Ajax check if the "ScriptResource.axd" HTTP handler is correctly registered in your web.config. Look for the following statement:

    ASP.NET 2.0:
    <add verb="GET,HEAD" path="ScriptResource.axd"
    type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

    ASP.NET 3.5
  4. <add path="ScriptResource.axd" verb="GET,HEAD"
    ="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" 
    ="false" /> 

    IIS7 Integrated Mode

    The following statement should be present in the <handlers> section instead of <httpHandlers>:

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

    Note: if you are using .NET 2.0 the version of the System.Web.Extensions assembly should be "1.0.61025.0". If you are using .NET 3.5 the version should be "". Always make sure you are referring to the right assembly version.
  5. If you are using RadControls for ASP.NET Ajax and RadScriptManager check if the Telerik.Web.UI.WebResource.axd HTTP handler is correctly registered in your web.config:

    ASP.NET 2.0:
    <add path="Telerik.Web.UI.WebResource.axd" verb="*"
    type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.1.619.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" 
    ="false" />  

    ASP.NET 3.5
    <add path="Telerik.Web.UI.WebResource.axd" verb="*"
    type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.1.619.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" 
    ="false" /> 

  6. IIS7

    The following statement should be present in the <handlers> section instead of <httpHandlers>:

    <add name="Telerik.Web.UI.WebResource" 
     path="Telerik.Web.UI.WebResource.axd" verb="*"  
    type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.1.619.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>   

    Note: The version in the HTTP handler registration statement will vary depending on the release date and .NET runtime (2.0 or 3.5). Always make sure you are referring to the right assembly version.

Dealing with the 500 error code (server error)

You should check the detailed error message. There are two common cases:

  1. "Padding is invalid and cannot be removed"
    The problem is likely to be related with the machine key. This blog post delves into why this error occurs. This MSDN article describes how to create a custom machine key.
  2. "Specified argument was out of the range of valid values. Parameter name: utcDate"
    The assembly containing the embedded resources is probably built in the future (its last modified time is later than the current time). This can occur when deploying in a different time zone. The solution is simple - run the following command line statement (the commas at the end are important!):
    copy /b <path to assembly which is built in the future>,,

I hope this helps.

About the Author

Atanas Korchev

 is Team Leader in Kendo UI Team

Related Posts


Comments are disabled in preview mode.