I'm having the hardest time getting bundling to work in Asp.Net MVC. I have EnableOptimizations set so that I can test the bundles before moving to prod.
Here is my RegisterBundles
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery/jquery-{version}.js",
"~/Scripts/jquery/jquery-migrate-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery/jquery-ui.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery/jquery.validate*",
"~/Scripts/jquery/jquery.unobtrusive*"));
BundleTable.EnableOptimizations = true;
Here's my _Layout
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqueryval")
However, when my page renders, it has these javascript errors. Which tells me that the jquery javascript wasn't loaded. It appears that html was returned. I believe when the bundle tries to retrieve the js, it's actually returning my login page again.
SyntaxError: expected expression, got '<' jquery:2:0
SyntaxError: expected expression, got '<' jqueryui:2:0
SyntaxError: expected expression, got '<' jqueryval:2:0
Any help is much appreciated.
If you are protecting parts of your site, then you'll need to exclude the path to the bundle from being protected.
Here is a solution to this problem from another question: https://stackoverflow.com/a/6304624/84395