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

梦想的初衷 提交于 2019-11-29 01:15:57

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.

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!