2016-01-13 18 views
0

我在WebForms項目中尋找一個奇怪的錯誤,我無法找到第二個jQuery參考的來源。如何在WebForms中找到流氓腳本調用的來源

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

現在這個包被稱爲在我的母版頁文件:

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

只要用戶停留在網頁的根文件夾(www.domain.com/page)evertyhing工作正常。不幸的是,當用戶被重定向到位於子文件夾的aspx頁面顯示(www.domain.com/subfolder/someotherpage)以下錯誤:

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

我搜索的整體解決方案,但無法找到部分,在這源自於。

綜觀呈現的源代碼,我看到這一點:

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

現在,這看起來並不像被捆綁提供的腳本標記,分別位於頭部。鑑於腳本標籤的位置,這應該從母版頁文件起源,但我不能把它我的手指:

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

之前你的建議吧:我已經試過用香草代替RadScriptManager asp:ScriptManager,但無濟於事。

是否有可能從asp.net web項目中的哪一行代碼中確定腳本引用來自哪裏,因此我可以消除它?

回答

0

因爲沒有明顯的純文本引用jQuery-1.10.2.js,它必須是Telerik中的錯誤或引用的程序集。

我沒有檢查安裝的Nuget軟件包。有安裝了一個,這是自動使用ScriptManager註冊的jQuery:

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

如果你安裝了這個,你不能再引用jQuery的,或者你可能會遇到$(...).functionName()不是一個函數錯誤。

因此,有這個問題2個可能的解決方案:

  1. 重新安裝該軟件包/更新這個包,並在你的母版頁文件中刪除所有其他提及的jQuery或
  2. 刪除此NuGet包與uninstall-package AspNet.ScriptManager.jQuery -project xxx