Why does ResolveBundleUrl not work for custom folders? (MVC Beta 4)

前端 未结 2 1779
你的背包
你的背包 2020-12-15 18:27

From a brand-new ASP.NET MVC 4 Beta Web Application, I\'m re-arranging my folders to match Rob Conery\'s VidPub.Web example

Specifically, this means that the final d

相关标签:
2条回答
  • 2020-12-15 19:05

    Under Application_Start in Global.asax.cs use BundleTable.Bundles.EnableDefaultBundles(); instead of BundleTable.Bundles.RegisterTemplateBundles();

    If you look at the source for RegisterTemplateBundles you can see that it actually only looks for (and adds) specific js and css files. EnableDefaultBundleson the other hand does pretty much the same as when you add you own bundles.

    0 讨论(0)
  • 2020-12-15 19:10

    It appears you have to register your own bundle when using non-default directories. I added the following to Application_Start and it fixed the problem

    var bundle = new Bundle("~/Public/stylesheets/css", new CssMinify());
    bundle.AddDirectory("~/Public/stylesheets", "*.css", true);
    BundleTable.Bundles.Add(bundle);
    
    bundle = new Bundle("~/Public/javascripts/js", new JsMinify());
    bundle.AddDirectory("~/Public/javascripts", "*.js", true);
    BundleTable.Bundles.Add(bundle);
    
    0 讨论(0)
提交回复
热议问题