1

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.

btorkelson
  • 89
  • 2
  • 10

1 Answers1

3

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

Community
  • 1
  • 1
Andy T
  • 10,223
  • 5
  • 53
  • 95
  • If you're using bundling, then the path to your scripts could be different in debug and release modes. You might need to allow access at `` in your release web.config file, and `` in your debug web.config file. – rockariotphobia Nov 27 '16 at 16:34