David Lindon
David Lindon

Reputation: 13

MVC3 script bundles just render empty script tag

When I view a page, all I can see is -

<script></script>

My _Layout.cshtml looks like

<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/helpdesk/Scripts")"></script>

Application_Start() in Global.asxc.cs looks like

protected void Application_Start() {
AreaRegistration.RegisterAllAreas();
BundleTable.Bundles.EnableDefaultBundles();

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}

Any ideas?

Upvotes: 0

Views: 496

Answers (1)

James
James

Reputation: 82096

Your using a custom directory which won't be covered by the default bundles. You would need to add a new bundle e.g.

var bundle = new Bundle("~/helpdesk/js", new JsMinify());
bundle.AddDirectory("~/helpdesk/js", "*.js", true);
BundleTable.Bundles.Add(bundle);

If your custom folder was within one of the default directories e.g. ~/Content/helpdesk/js / ~/Scripts/helpdesk/ then you wouldn't have to do this.

Upvotes: 2

Related Questions