JavaScript error in Asp.Net MVC 4 Bundling

When I use the following Bundling in MVC 4, my application receives several JavaScript errors, such as "jQuery undefined"

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js",
                    "~/Scripts/jquery-ui-{version}.js",
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

But when I use the approach below, my application works without JavaScript errors:

        bundles.Add(new ScriptBundle("~/bundles/jquery1").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jquery2").Include(
                    "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jquery3").Include(
                    "~/Scripts/jquery.unobtrusive*"));

        bundles.Add(new ScriptBundle("~/bundles/jquery3").Include(
                    "~/Scripts/jquery.validate*"));

My question is: what is the problem?

+5
source share
2 answers

This is because your scripts are in the wrong order. You must ensure that your version of the Web Optimization Framework is up to date. This answer contains additional information:

fooobar.com/questions/64078 / ...

And the NuGet package:

http://nuget.org/packages/Microsoft.AspNet.Web.Optimization

+3
source

Decision:

Microsoft.AspNet.Web.Optimization 1.0.0 1.1.0-Beta1, .

+2

All Articles