Reputation:
I have created a bundle of js files ("bundles/js") in which I included all js files that were required for the page.
@Scripts.Render("/bundles/js")
and after rendering it throws error for above line :
Failed to load resource: the server responded with a status of 404 (Not Found)
and after rendering it appears like
<script scr="/bundles/js">
but nothing works on page.
I have commented the references to all js files and put the render but it doesn't work.
I have include optimization dll in project, in web.config and also added bundlesConfig class
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/js").Include("~/Content/js/jquery.min.js",
"~/Content/js/bootstrap.min.js",
"~/Content/js/owl.carousel.js",
"~/Content/js/jquery.ajaxchimp.js",
"~/Content/js/smooth-scroll.js",
"~/Content/js/jquery.magnific-popup.min.js",
"~/Content/js/waypoints.min.js",
"~/Content/js/jquery.counterup.js",
"~/Content/js/menumaker.js",
"~/Content/js/jquery.appear.js",
"~/Content/js/jquery.countdown.js",
"~/Content/js/price-slider.js",
"~/Content/js/bootstrap-datepicker.js",
"~/Content/js/jquery.elevatezoom.js",
"~/Content/js/theme.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.min.js",
"~/Scripts/DataTables/jquery.dataTables.min.js",
"~/Content/sweetalert/sweetalert.min.js",
"~/Scripts/DataTables/dataTables.buttons.min.js",
"~/Scripts/DataTables/buttons.flash.min.js",
"~/Scripts/DataTables/pdfmake.min.js",
"~/Scripts/DataTables/vfs_fonts.js",
"~/Scripts/DataTables/buttons.html5.min.js",
"~/Scripts/DataTables/buttons.print.min.js",
"~/Content/js/blockUI.js"));
}
}
and then registered in application_start
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
Previous sequence of files was:
<script src="~/Content/js/bootstrap.min.js"></script>
<script src="~/Content/js/owl.carousel.js"></script>
<script src="~/Content/js/jquery.ajaxchimp.js"></script>
<script src="~/Content/js/smooth-scroll.js"></script>
<script src="~/Content/js/jquery.magnific-popup.min.js"></script>
<script src="~/Content/js/waypoints.min.js"></script>
<script src="~/Content/js/jquery.counterup.js"></script>
<script src="~/Content/js/menumaker.js"></script>
<script src="~/Content/js/jquery.appear.js"></script>
<script src="~/Content/js/jquery.countdown.js"></script>
<script src="~/Content/js/price-slider.js"></script>
<script src="~/Content/js/bootstrap-datepicker.js"></script>
<script src="~/Content/js/jquery.elevatezoom.js"></script>
<script src="~/Content/js/theme.js"></script>
<script src='@Url.Content("~/Scripts/jquery.validate.min.js")' type='text/javascript'></script>
<script src='@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")' type='text/javascript'></script>
<script src="~/Scripts/DataTables/jquery.dataTables.min.js"></script>
<script src="~/Content/sweetalert/sweetalert.min.js"></script>
<script src="~/Scripts/DataTables/dataTables.buttons.min.js"></script>
<script src="~/Scripts/DataTables/buttons.flash.min.js"></script>
<script src="~/Scripts/DataTables/pdfmake.min.js"></script>
<script src="~/Scripts/DataTables/vfs_fonts.js"></script>
<script src="~/Scripts/DataTables/buttons.html5.min.js"></script>
<script src="~/Scripts/DataTables/buttons.print.min.js"></script>
<script src="~/Content/js/blockUI.js"></script>
Upvotes: 1
Views: 729
Reputation: 62
//Add into web config
<system.web>
<compilation debug="false" />
</system.web>
public static void RegisterBundles(BundleCollection bundles)
{
//Enable bundling
BundleTable.EnableOptimizations = true;
}
Upvotes: 1
Reputation: 941
You missing a tilde in @Scripts.Render("/bundles/js")
Try - @Scripts.Render("~/bundles/js")
Upvotes: 0