before start let me know there other questions on issues have great answers please let me explain how mine different.
i have asp.net mvc 5 project have collection of bundles:
public class bundleconfig { // more information on bundling, visit http://go.microsoft.com/fwlink/?linkid=301862 public static void registerbundles(bundlecollection bundles) { bundles.add(new scriptbundle("~/bundles/jquery").include( "~/scripts/jquery.js")); bundles.add(new scriptbundle("~/bundles/jqueryval").include( "~/scripts/jquery.validate*")); // use development version of modernizr develop , learn from. then, when you're // ready production, use build tool @ http://modernizr.com pick tests need. bundles.add(new scriptbundle("~/bundles/modernizr").include( "~/scripts/modernizr-*")); bundles.add(new scriptbundle("~/bundles/bootstrap").include( "~/scripts/bootstrap.js")); bundles.add(new stylebundle("~/content/css").include( "~/content/bootstrap.css", "~/content/freelancer.css")); // plugin javascript bundles.add(new scriptbundle("~/bundles/pluginjs").include( "~/scripts/cbpanimatedheader.js", "~/scripts/classie.js")); //custom theme js bundles.add(new scriptbundle("~/bundles/customthemejs").include( "~/scripts/freelancer.js")); // contact form javascript bundles.add(new scriptbundle("~/bundles/contactvalidation").include( "~/content/jqbootstrapvalidation.js", "~/content/contact_me.js")); }
these called in _layout.cshtml
:
@scripts.render("~/bundles/customthemejs") @scripts.render("~/bundles/jquery") @scripts.render("~/bundles/contactvalidation") @scripts.render("~/bundles/pluginjs") @scripts.render("~/bundles/bootstrap") @rendersection("scripts", required: false) </body> </html>
and in `global.asax:
protected void application_start() { arearegistration.registerallareas(); filterconfig.registerglobalfilters(globalfilters.filters); routeconfig.registerroutes(routetable.routes); bundleconfig.registerbundles(bundletable.bundles); }
here know far:
- all
stylebundle
's called , invoked can pin point problem within script referencing - the scripts referred in correct folder i.e ~/scripts/.... know isn't referencing issue.
- the scripts working have tested them using web forms project
- i have tried referencing bundles in
head
section of_layout.cshtml
no change - dev tools in chrome , debugger in vs show the script not being run
- my suspicion there gap somewhere between call
_layout.cshtml
, bundles inbundleconfig
class
i have tried other solutions others have recommended around web such looking syntax errors etc... far aware there none.
to make structure of scripts obvious have included screen shot:
can see in different perspective myself , see have gone wrong?
your code looks correct, though referencing microsoft.web.optimization
application config
may not working correctly. can force reference application utilize web.optimization
. inside of _layout.cshtml
above bundled data, place following:
@using system.web.optimization
that should correctly enforce web.optimization
.
the other part may wrong, can't see global.asax. need ensure call registerbundle
.
bundleconfig.registerbundle(bundletable.bundles);
Comments
Post a Comment