I am using bundling and minification with MVC 3 with .NET Framework 4. Created BundleConfig.cs and placed under App_Data folder.
Called BundleConfig.RegisterBundles(BundleTable.Bundles); from Application_Start() of Global.asax file.
From master file I called
<% Styles.Render("~/Content/themes/base"); %>
<% Scripts.Render("~/Scripts","~/Scripts/Controllers","~/Scripts/Views");%>
on header tag.
However CSS not rendered as expected and jQuery not recognized as Scripts.Render does not work as expected.
My BundleConfig.cs class definition follows here…
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/Content/themes/base").Include(
"~/Content/themes/base/Blueprint-Liquid.css",
"~/Content/themes/base/ex.css",
"~/Content/themes/base/exNav.css",
"~/Content/themes/base/ie.css",
"~/Content/themes/base/jquery-ui-1.8.14.custom.css",
"~/Content/themes/base/jquery.qtip.css",
"~/Content/themes/base/reset.css",
"~/Content/themes/base/Site.css",
"~/Content/themes/base/structure-fixed.css",
"~/Content/themes/base/structure-fluid.css",
"~/Content/themes/base/tipsy.css",
"~/Content/themes/base/typography.css",
"~/Content/themes/base/ui.jqgrid.css")
);
bundles.Add(new ScriptBundle("~/Scripts/Controllers").Include(
"~/Scripts/Controllers/ProjectController.js",
"~/Scripts/Controllers/RequestController.js",
"~/Scripts/Controllers/SystemController.js")
);
bundles.Add(new ScriptBundle("~/Scripts/Views").Include(
"~/Scripts/Views/ProjectView.js",
"~/Scripts/Views/RequestView.js",
"~/Scripts/Views/SystemView.js")
);
bundles.Add(new ScriptBundle("~/Scripts").Include(
"~/Scripts/Dialog.js",
"~/Scripts/EX.Computing.js",
"~/Scripts/exNav.js",
"~/Scripts/grid.locale-en.js",
"~/Scripts/jquery-1.6.2.js",
"~/Scripts/jquery-1.6.2.min.js",
"~/Scripts/jquery-ui-1.8.14.js",
"~/Scripts/jquery-ui-1.8.14.min.js",
"~/Scripts/jquery.jqGrid.fluid.js",
"~/Scripts/jquery.jqGrid.min.js",
"~/Scripts/jquery.jqGrid.src.js",
"~/Scripts/jquery.qtip.js",
"~/Scripts/jquery.tipsy.js",
"~/Scripts/jquery.jquery.unobtrusive-ajax.js",
"~/Scripts/jquery.jquery.unobtrusive-ajax.min.js",
"~/Scripts/jquery.jquery.validate-vsdoc.js",
"~/Scripts/jquery.validate.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery.validate.unobtrusive.min.js",
"~/Scripts/json2.js",
"~/Scripts/Labels.js",
"~/Scripts/modernizr-1.7.js",
"~/Scripts/SessionTimeOut.js",
"~/Scripts/underscore.js")
);
BundleTable.EnableOptimizations = true;
}
I am wondering what I am missing? Any help grately appreciated!
Thanks,
Ramani
When I started using Bundling and Minification I am not sure whether it works with MVC3, and
found it works without any issues. I thought of sharing my code here so that it helps someone.