ScriptManager loads multiple Telerik.Web.UI.WebResource.axd files

13 posts, 0 answers
  1. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 06 Jun 2013 Link to this post

    I have several JS files that were linked on my site and I wanted to combine them into just one call, so, I added this to the RadScriptManager

    <CompositeScript>
        <Scripts>
            <asp:ScriptReference Path="~/js/jquery.min.js" ScriptMode="Auto" />
            <asp:ScriptReference Path="~/js/webctrl.js" ScriptMode="Auto" />
            <asp:ScriptReference Path="~/js/default.js" ScriptMode="Auto" />
            <asp:ScriptReference Assembly="System.Web" Name="WebForms.js" ScriptMode="Auto" /> 
        </Scripts>
    </CompositeScript>

    Now, whenever I view the site, the above scripts are combines, however, the original Telerik resource file that was being loaded is now at least 2 files and sometimes 3 or more.

    I have noticed that the order in which they are loading has changed. Originally, the static resources would be served first, then a single combined telerik resource file. Now, a telerik resource file is served first that contains only basic MS ajax code, then the combined static resources, then one or more telerik resource files.

    I'd like to include everything into one resource file if possible, but I'm not sure that is even able to be done.
  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 11 Jun 2013 Link to this post

    Hi Keith,

    Please remove the following tag "<CompositeScript>" and the files should be combined into one file.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 11 Jun 2013 Link to this post

    Removing the CompositeScript tags resulted in an error with the page.

     

    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Web.UI.ScriptEntry.GetSerializedAssemblyInfo() +149
       Telerik.Web.UI.ScriptEntrySlot.SerializeScriptEntry(ScriptEntry scriptEntry) +28
       Telerik.Web.UI.ScriptEntryUrlBuilder.TryAddScriptEntry(ScriptEntry scriptEntry) +30
       Telerik.Web.UI.ScriptEntryUrlBuilder.RegisterScriptEntry(ScriptEntry scriptEntry) +205
       Telerik.Web.UI.RadScriptManager.OnResolveScriptReference(ScriptReferenceEventArgs e) +546
       System.Web.UI.ScriptManager.RegisterScripts() +263
       System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +122
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +9008698
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2716
  5. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 12 Jun 2013 Link to this post

    Hi Keith,

    In order to debug and resolve you case could you please send me the sample project which reproduces the issue and also clarify which version of our controls are you using?

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 12 Jun 2013 Link to this post

    The project is quite large and complex, so breaking out a small part will not be possible. I did resolve the error by removing this line:

     

     

     

    <telerik:RadScriptReference Combine="true" Assembly="System.Web" Name="WebForms.js" ScriptMode="Auto" />

     

     

     

     



    however, now none of the scripts are combined into a single resource, which is what <CompositeScript> is supposed to be doing.

  7. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 17 Jun 2013 Link to this post

    Hi Keith,

    CompositeScript comes from the standard script manager. It combines the listed scripts into one.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  8. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 17 Jun 2013 Link to this post

    Yes, exactly. I want all of the scripts used on the page to be combined into one single script file. This is what should be happening with CombineScript .. however:

    If you look at my first post, you will see that I have 4 files listed in CombineScript. If I remove all of them and simply list them as script files for the manager, what I end up with is 5 script files, the one Telerik script file (webresource.axd) and the 4 listed script files. So, thinking i want to have a single resource file of scripts, I use CombineScripts to add the 4 scripts to the file. The result is that scripts that were being combined are now, in some circumstances, not being combined, so instead of receiving a single scriptresource.axd file I receive 4 telerik webresource.axd files one scriptresource.axd file. Same number of script files, sometimes more, sometimes less, for reasons which I cannot figure out ... but never do they combine into a single resource file.
  9. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 20 Jun 2013 Link to this post

    Hello Keith,

    Using CombineScripts it will combine only the scripts that are listed in that section. You described really strange behavior which we have never experienced. When you specify script folder the files should be combined into single one. Without a runnable sample to debug it will be hard to identify and resolve the problem.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  10. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 20 Jun 2013 Link to this post

    Ok, here is a complete page that exhibits the issue I am attempting to resolve.

    You will note that if the CompositeScript tag is removed from the aspx file, the script WebForms.js that is specified generates an error (at least it does for me). Upon removal of that line as well, the following script files are loaded with the page:
    • WebResource.axd
    • Telerik.Web.UI.WebResource.axd
    • jquery-1.4.1.js
    • spm.js

     

    When you add the CompositeScript tag and the WebForms.js item to be compressed into a ScriptResource.axd, the following script files are loaded with the page:
    • Telerik.Web.UI.WebResource.axd
    • Telerik.Web.UI.WebResource.axd
    • ScriptResource.axd

     

    In the page without the composite script tag, the file WebResource.axd contains the resources from System.Web, namely WebForms.js; Telerik.Web.UI.WebResource.axd contains the resources from Telerik.Web.UI:
    • MicrosoftAjax.js
    • MicrosoftAjaxWebForms.js
    • Common.Core.js
    • Ajax.Ajax.js
    • Common.jQuery.js
    • Common.jQueryPlugins.js
    • Common.TouchScrollExtender.js
    • Common.Navigation.OData.OData.js
    • Common.Navigation.NavigationScripts.js
    • ComboBox.RadComboBoxScripts.js
    • ListBox.RadListBoxScripts.js
    • Button.RadButton.js

    Then there are the two uncompressed files:
    • jquery-1.4.1.js
    • spm.js

    When the CompositeScript tag is used, the first Telerik.Web.UI.WebResource.axd file contains:
    • MicrosoftAjax.js
    • MicrosoftAjaxWebForms.js
    • function loadHandler

    The second Telerik.Web.UI.WebResource.axd file contains the remaining script resource files from Telerik.Web.UI listed above.

    Finally the ScriptResource.axd file contains:
    • jquery-1.4.1.js
    • WebForms.js
    • spm.js

    Note that the original Telerik.Web.UI.WebResource.axd file is now two files. So, while it did create a composite of three script files, the one that was a composite before has been split into two files.

    This particular example only shows the originally composited file being split into two files, however, I have other instances where it has been split into three Telerik.Web.UI.WebResource.axd files.

    On a final note, this particular page is designed to be viewed in a RadWindow. I've removed the static header and footer controls for clarity as they are displayed when viewed outside a RadWindow. This allows me to provide an empty CodeBehind file.

    spm.aspx
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="spm.aspx.vb" Inherits="WebApplication1.Spm" %>
      
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
      
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadListBox1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="CheckBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadListBox1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadListBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Panel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="Panel1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="form1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
           <CompositeScript>
            <Scripts>
                <telerik:RadScriptReference Path="~/js/jquery-1.4.1.js" />
                <telerik:RadScriptReference Assembly="System.Web" Name="WebForms.js" />
                <telerik:RadScriptReference Path="~/js/spm.js" />
            </Scripts>
            </CompositeScript>
        </telerik:RadScriptManager>
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" OutputCompression="AutoDetect"
            runat="server">
            <StyleSheets>
                <telerik:StyleSheetReference Path="~/css/spm.css" />
            </StyleSheets>
        </telerik:RadStyleSheetManager>
        <div id="Div1" runat="server">
            <div id="Div2">
                <div>
                    <asp:Label ID="Label5" Text="Label1:" runat="server"></asp:Label>
                    <telerik:RadComboBox ID="RadComboBox1" runat="server">
                    </telerik:RadComboBox>
                    <span id="Span1">
                        <asp:CheckBox ID="CheckBox1" Text="CheckBox1" runat="server" AutoPostBack="true" />
                    </span>
                    <telerik:RadListBox ID="RadListBox1" runat="server" AutoPostBack="false">
                    </telerik:RadListBox>
                    <asp:Panel ID="Panel1" runat="server">
                        <div id="Div3" class="gbx_wrapper">
                            <div class="gbx">
                                <asp:Label CssClass="gbx_label" Text="Label" runat="server"></asp:Label>
                                <span id="Span2">
                                    <asp:CheckBox ID="CheckBox2" Text="CheckBox2" runat="server" AutoPostBack="false" />
                                </span>
                                <asp:Label ID="Label1" Text="Last Name:" runat="server"></asp:Label>
                                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                <asp:Label ID="Label2" Text="First Name:" runat="server"></asp:Label>
                                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                                <asp:Label ID="Label3" Text="Message For:" runat="server"></asp:Label>
                                <asp:Label ID="Label4" Text="N/A" runat="server"></asp:Label>
                                <telerik:RadButton ID="RadButton1" runat="server" Text="New" Width="66px" Skin="Default">
                                </telerik:RadButton>
                                <telerik:RadButton ID="RadButton2" runat="server" Text="Edit" Width="66px" Skin="Default">
                                </telerik:RadButton>
                                <telerik:RadButton ID="RadButton3" runat="server" Text="Cancel" Width="66px" Skin="Default">
                                </telerik:RadButton>
                            </div>
                        </div>
                    </asp:Panel>
                    <telerik:RadButton ID="RadButton4" runat="server" Text="Done" AutoPostBack="false"
                        OnClientClicked="CloseMe" Skin="Default">
                    </telerik:RadButton>
                </div>
            </div>
        </div>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" InitialDelayTime="100"
            MinDisplayTime="1000" Skin="Default" Transparency="60">
        </telerik:RadAjaxLoadingPanel>
        </form>
    </body>
    </html>

    spm.aspx.vb
    Public Class Spm
        Inherits System.Web.UI.Page
      
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      
        End Sub
      
    End Class

    Web.config
    <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      -->
    <configuration>
      <appSettings>
        <add key="Telerik.ScriptManager.TelerikCdn" value="Disabled" />
        <add key="Telerik.StyleSheetManager.TelerikCdn" value="Disabled" />
        <add key="Telerik.Web.UI.StyleSheetFolders" value="~/css/" />
      </appSettings>
      <system.web>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
            <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
          </assemblies>
        </compilation>
        <pages>
          <controls>
            <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
          </controls>
        </pages>
        <httpHandlers>
          <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
        </httpHandlers>
      </system.web>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
          <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
        </handlers>
      </system.webServer>
    </configuration>

    spm.css
    html, body
    {
        background: none repeat scroll 0 0 #464646;
        height: 277px;
        overflow: hidden;
        width: 558px;
        color: #D7D7D7;
        font-family: Sans-Serif;
        font-size: 8.25pt;
    }
    #Label5
    {
        left: 24px;
        position: absolute;
        top: 12px;
    }
    #RadComboBox1
    {
        left: 22px;
        position: absolute;
        top: 28px;
        width: 228px !important;
    }
    #Span1
    {
        left: 18px;
        position: absolute;
        top: 52px;
    }
    #RadListBox1
    {
        height: 179px;
        left: 22px;
        position: absolute;
        top: 75px;
        width: 228px !important;
    }
    #RadListBox1 div
    {
        height: 179px;
        overflow: auto !important;
    }
    #Div3
    {
        height: 240px;
        left: 276px;
        position: absolute;
        top: 20px;
        width: 285px;
    }
    .gbx
    {
        min-height: 233px;
        border: 1px solid #000000;
        border-radius: 5px 5px 5px 5px;
    }
    .gbx_label
    {
        left: 10px;
        position: absolute;
        top: -8px;
        background-color: #464646;
        padding-left: 5px;
        padding-right: 5px;
        z-index: 100;
    }
    #Span2
    {
        left: 209px;
        position: absolute;
        top: 20px;
    }
    #Label1
    {
        left: 24px;
        position: absolute;
        top: 47px;
    }
    #TextBox1
    {
        left: 23px;
        position: absolute;
        top: 66px;
        width: 238px;
    }
    #Label2
    {
        left: 24px;
        position: absolute;
        top: 94px;
    }
    #TextBox2
    {
        left: 23px;
        position: absolute;
        top: 113px;
        width: 238px;
    }
    #Label3
    {
        left: 24px;
        position: absolute;
        top: 144px;
    }
    #Label4
    {
        font-weight: bold;
        left: 24px;
        position: absolute;
        text-align: center;
        top: 165px;
        width: 241px;
    }
    #RadButton1
    {
        left: 20px;
        position: absolute;
        top: 198px;
    }
    #RadButton2
    {
        left: 108px;
        position: absolute;
        top: 198px;
    }
    #RadButton3
    {
        left: 195px;
        position: absolute;
        top: 198px;
    }
    #RadButton4
    {
        left: 509px;
        position: absolute;
        top: 262px;
    }
    span label
    {
        position: absolute;
        top: 3px;
        width: 100px;
    }

    spm.js
    function CloseMe(sender, args) {
        var oWindow = null;
        if (window.RadWindow)
            oWindow = window.radWindow;
        else if (window.frameElement.radWindow)
            oWindow = window.frameElement.radWindow;
        oWindow.close();
    }
  11. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 25 Jun 2013 Link to this post

    Hello Keith,

    I setup a sample project from the provided snippets. The scripts are combined in one request. You should specify the "Telerik.Web.UI.ScriptFolders" in your web config. Regarding to the System.Web and the WebForms script there is an issue when we try to load an assembly which is referenced from the GAC. For your case you do not need to worry about it. The script will be automatically loaded by the ScriptManager.
    I am sending you the example for a reference.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  12. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 25 Jun 2013 Link to this post

    Still not working.

    I added this line to the web.config file:
    <add key="Telerik.Web.UI.ScriptFolders" value="~/js/;" />

    I then changed this:
    <telerik:RadScriptManager ID="RadScriptManager1" OutputCompression="AutoDetect" runat="server">
        <CompositeScript>
            <Scripts>
                <telerik:RadScriptReference Path="~/js/jquery-1.4.1.min.js" />
                <telerik:RadScriptReference Assembly="System.Web" Name="WebForms.js" />
                <telerik:RadScriptReference Path="~/js/spm.js" />
            </Scripts>
        </CompositeScript>
    </telerik:RadScriptManager>


    to this:
    <telerik:RadScriptManager ID="RadScriptManager1" OutputCompression="AutoDetect" runat="server">
    <Scripts>
                <telerik:RadScriptReference Path="~/js/jquery-1.4.1.min.js" />
                <telerik:RadScriptReference Path="~/js/spm.js" />
    </Scripts>
    </telerik:RadScriptManager>


    Doing so changed the number of scripts loaded in the page from 3 to 6 as shown in the attached images from my testing environment.
  13. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 28 Jun 2013 Link to this post

    Hi Keith,

    It is really strange. Could you clarify that you are using at least Q1.2013 or higher version of our control? The feature of external script combining comes with Q1.2013. In case that you are using that version please setup a runnable project with the DLLs and send it back for a test.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  14. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 30 Jun 2013 Link to this post

    That may indeed be the problem. The controls are Q3.2012

    I'll see about getting the latest binaries and see if the problem still exists.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017