I am currently facing the problem that on one of my pages, the page requests a file named "jquery-ui-1.11.1.min.js" which causes a 404 file not found error. This is because the correct file name is "jquery-ui.min-1.11.1.js". So, for some reason, something uses wrong jquery references.
My MasterPage has the following references (among others):
<asp:ScriptManager runat="server" EnablePageMethods="true" LoadScriptsBeforeUI="true"> <Scripts> <asp:ScriptReference Name="MsAjaxBundle" /> <asp:ScriptReference Name="jquery" /> <asp:ScriptReference Name="jquery.ui.combined" /> </Scripts> </asp:ScriptManager>
What I have tried:
Another way of solving this would be to simply add a copy of the JS file and rename it so that it matches the requested file's name. But then again, this is a very dirty solution because it doesn't solve the root cause of problem.
The missing file causes problems like not-working datepicker, etc. I have temporarily solved it by putting this on top of the page:
<script type="text/javascript" src='<%= ResolveClientUrl("~/Scripts/jquery-ui.min-1.11.1.js") %>'></script>
However, this is terrrible to maintain, so I would like to have the following things:
To me, bundling is still a blackbox and I couldn't find any usable solution to include everything that jQuery needs onthe MasterPage. Any suggestions?
I have found the cause of the problem. The following line in BundeConfig.cs was the reason for the wrong request:
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
This apparently also included the "min" version of jquery-ui.
My solution for bundling jquery now is:
bundles.Add(new ScriptBundle("~/bundles/jquery")
.Include("~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js"));
This solves the maintainability issue and causes all pages that use the Site.Master to correctly use jQuery.