asp.nettelerikscriptmanagerasp.net-bundling

How to find the source of a rogue script call in WebForms


I'm hunting down a weird error in a WebForms project, where I can't find the source of a second jQuery reference.

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
        "~/Scripts/jquery-1.10.2.min.js",
        //additional entries omitted
    ));

Now this bundle is called in my master page file:

<asp:PlaceHolder runat="server">
    <%: Scripts.Render("~/bundles/jquery") %>
    <%: Styles.Render("...") %>
</asp:PlaceHolder>

As long as the user stays in the root folder of the webpage (www.domain.com/page) evertyhing works fine. Unfortunately, when the user gets redirected to a aspx page located in a subfolder (www.domain.com/subfolder/someotherpage) the following error appears:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:53078/Scripts/jquery-1.10.2.js

I've searched the whole solution, but can't find the part, where this originates from.

Looking at the rendered source code I see this:

<body>
   <script src="../Scripts/jquery-1.10.2.js" type="text/javascript"></script>
</body>

Now this does not look like the script tags rendered by the bundling, which are located in the head. Given the position of the script tag, this should originate from the master page file, but I can't put my finger on it:

<head runat="server">
    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/jquery") %>
        <%: Styles.Render("~/bundles/Stylesheets") %>
    </asp:PlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" EnableEmbeddedjQuery="false">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryExternal.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryPlugins.js" />
            </Scripts>
        </telerik:RadScriptManager>

    <%: Scripts.Render("~/bundles/UiEffects") %>
</body>

Before you suggest it: I've tried replacing the RadScriptManager with a vanilla asp:ScriptManager, but to no avail.

Is it possible to determine, from which line of code in an asp.net web project the script refernce originates, so I can eliminate it?


Solution

  • Since, there was no obvious plain text reference to jQuery-1.10.2.js, it had to be either a bug in Telerik or a referenced assembly.

    I did not check the installed Nuget packages. There was one installed, which was automatically registering jQuery with the ScriptManager:

    http://www.nuget.org/packages/AspNet.ScriptManager.jQuery/1.10.2

    If you have this installed, you must not reference jQuery again, or you might run into $(...).functionName() is not a function errors.

    So, there are 2 possible solutions to this problem:

    1. Re-install this package / update this package and remove every other reference to jQuery in your master page file or
    2. Remove this NuGet package with uninstall-package AspNet.ScriptManager.jQuery -project xxx