Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is jqueryval bundle rendering empty?

I am trying to render a script bundle but it is coming up empty.

Here's the script bundle declaration in BundleConfig.cs

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

bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                  "~/Scripts/modernizr-*"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js"));

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                  "~/jquery.unobtrusive.ajax*",
                  "~/jquery.validate.unobtrusive.bootstrap*"));

And in my view

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jqueryval")

But when I load the page, the jqueryval script comes up empty.

<script src="/bundles/jquery?v=Nsx6sB8o7LJCR51P5u-dfe-6LePnt87pD0P5VTJ-0wI1"></script>

<script src="/bundles/bootstrap?v=XkxfR798CUJPhMhSd0B8VYgZWSNOTtLvz6047jf84wQ1"></script>

<script src="/bundles/modernizr?v=K-FFpFNtIXPUlQamnX3qHX_A5r7TM2xbAgcuEmpm3O41"></script>

<script src="/bundles/jqueryval?v="></script>

The debugger in Firefox says returns a 200 status when retrieving the files for the bundle, but the filesize is 0.

like image 230
mvanella Avatar asked Dec 04 '25 05:12

mvanella


1 Answers

Most likely, your paths are incorrect. This:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                  "~/jquery.unobtrusive.ajax*",
                  "~/jquery.validate.unobtrusive.bootstrap*"));

should be

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                  "~/scripts/jquery.unobtrusive.ajax*",
                  "~/scripts/jquery.validate.unobtrusive.bootstrap*"));

Remember, ~/ maps to the site's virtual root directory when the path is being resolved, so unless you're placing JavaScript files in the site root, those paths in your bundle will not work.

like image 147
Tieson T. Avatar answered Dec 05 '25 19:12

Tieson T.