How to use ASP.NET 4.5 Bundling & a CDN to get Bootstrap 3.2?

507 views Asked by At

I am a new ASP.NET developer and I am trying to use one of the greatest features of ASP.NET 4.5 which is Bundling feature. It appears to have some support for use of CDNs. I am struggling right now in using Bundling for getting the bootstrap 3.2.0. So how can I do that?

Here's a snippet of my code:

public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.UseCdn = true;   //enable CDN support

            //add link to jquery on the CDN
            var cssCdnPath = "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css";

            bundles.Add(new StyleBundle("~/bundles/css",
                      cssCdnPath).Include(
                      "~/Assets/css/bootstrap-{version}.css"));
}
1

There are 1 answers

0
AudioBubble On

The CDN location is only used when the BundleTable.EnableOptimizations is configured to be true.

Simple add the following to the RegisterBundles method:

BundleTable.EnableOptimizations = true;