2013-01-07 41 views
0

當我瀏覽一個頁面,我可以看到的是 -MVC3腳本捆包只呈現空腳本標籤

<script></script>

我_Layout.cshtml看起來像

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

Application_Start()Global.asxc.cs看起來像

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

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

有什麼想法?

回答

2

您使用的是不包含在默認包中的自定義目錄。您需要添加一個新的包,例如

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

如果您的自定義文件夾位於其中一個默認目錄中,例如~/Content/helpdesk/js/~/Scripts/helpdesk/那麼你不必這樣做。

+0

+1他的anaswer加上你可以解決使用BundleTable.Bundles.GetRegisteredBundles(); – heads5150